i am facing this error when i select row and load into dropdownlist, null value is coming in dropdown
There is no row at position 0.
string SesnId1 = dm.GetData("select IDUOM from dbo.UOM where NameUOM='" + GVitem.SelectedRow.Cells[4].Text.Trim() + "'").Rows[0][0].ToString();
so how it will tackle...
protected void GVitem_SelectedIndexChanged(object sender, EventArgs e)
{
txtID.Text = GVitem.SelectedRow.Cells[1].Text;
txtnam.Text = GVitem.SelectedRow.Cells[2].Text;
txtaltID.Text = GVitem.SelectedRow.Cells[6].Text;
txtweight.Text = GVitem.SelectedRow.Cells[9].Text;
string SesnId1 = dm.GetData("select IDUOM from dbo.UOM where NameUOM='" + GVitem.SelectedRow.Cells[4].Text.Trim() + "'").Rows[0][0].ToString();
string SesnId2 = dm.GetData("select SecID from dbo.Sections where Secnam='" + GVitem.SelectedRow.Cells[7].Text.Trim() + "'").Rows[0][0].ToString();
DDUOM.SelectedValue = SesnId1;
string SesnId3 = dm.GetData("select TID from dbo.Item_Type where TName='" + GVitem.SelectedRow.Cells[5].Text.Trim() + "'").Rows[0][0].ToString();
DDPack.SelectedValue = SesnId3;
DDSec.SelectedValue = SesnId2;
//DDUOM.SelectedItem.Text = GridView1.SelectedRow.Cells[4].Text;
//DDPack.SelectedItem.Text = GVitem.SelectedRow.Cells[6].Text;
txtbs.Text = GVitem.SelectedRow.Cells[3].Text;
// DDPack.Items.Add(GVitem.SelectedRow.Cells[5].Text.ToString());
}