I have gridview and I added edit function to update grid content as when user click on edit button panel displayed with fields have grid content and user can edit on the data one of these data drop down which have location data . but when I click on edit button all fields have grid content but the DDL have the first item at first time and when I click the edit again DDL have the right item . So what it the problem?
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "editrow")
{
GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
TextBox name = row.FindControl("Lbl_Name") as TextBox;
TextBox address = row.FindControl("Lbl_Address") as TextBox;
Label mobile = row.FindControl("Lbl_Mobile") as Label;
Label tele = row.FindControl("Lbl_Tele") as Label;
Label area = row.FindControl("Lbl_Area_ID") as Label;
Label location = row.FindControl("Lbl_Loc_ID") as Label;
Label category = row.FindControl("Lbl_Cat_ID") as Label;
txt_adr.Text = address.Text;
txt_mobile.Text = mobile.Text;
txt_name.Text = name.Text;
txt_tele.Text = tele.Text;
ddl_category.SelectedValue = category.Text;
//the problem here on ddloc
ddloc.SelectedValue = location.Text;
DDL_AREA.SelectedValue = area.Text;
}
}
Instead of
use