Saturday, November 17, 2007

Parent Child Relation between two dropdown in a gridview

To change the drop down value form the other dropdown selected index change.

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = (GridViewRow)((sender) as Control).NamingContainer;
DropDownList dr = (DropDownList)sender;
//DropDownList dr = (DropDownList)GridView1.FindControl("DropDownList1");

DropDownList dropdown2 =(DropDownList)row.FindControl("DropDownList2");
string condition = dr.SelectedValue.ToString();
SelectSubCategory(condition,dropdown2);//a function for filling the child gridview
}

No comments: