Tuesday, July 03, 2007

Binding 2 Drop Downs in a grid view???

whenever u have 2 drop downs in a gridview and wanna bind one drop down due 2 post back of otheruse this
protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
{
string foundID = String.Empty;
GridViewRow row = (GridViewRow)((sender) as Control).NamingContainer;
// get the value from the first dropdownlist
DropDownList ddlFirst = ((sender) as DropDownList);
int ddlFirstSelectedValue = Convert.ToInt32(ddlFirst.SelectedValue);
string firstDropDownListID = ddlFirst.UniqueID;
// and now here is how
DropDownList ddlSecond = row.FindControl("ddl2") as DropDownList;
// now from here you can do whatever you want!
}

No comments: