help related to a SelectedIndexChanged event
help related to a SelectedIndexChanged event of a dropdownlist inside a GridView control in asp.net 2.0
I am using asp.net 2.0.
I have a dropdownlist control inside a gridview control. On selecting an item in the dropdownlist, I am able to display related data in other two columns of the grid in the same row. But the problem -> the moment i choose another item from the dropdownlist data just get cleared from the previous line. This is happening in every row.
protected void GridView1_SelectedIndexChanged(object sender,
EventArgs e)
{
string selectedtext = ((DropDownList)
GridView1.SelectedRow.FindControl
("ddlicode")).SelectedItem.Value;
GridViewRow row = GridView1.SelectedRow;
comm = new SqlCommand("select item_code,item_desc from
ItemMast where item_desc='" + selectedtext + "'", conn);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
while (dr.Read())
{
((Label)row.FindControl("lblicode")).Text = dr.GetValue
(0).ToString().Trim();
((Label)row.FindControl("lblidesc")).Text = dr.GetValue
(1).ToString().Trim();
}
conn.Close();
}
|