Thursday, December 17, 2009

How to Poppulate a dropdown in a gridview in Row Editing

protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow &&
(e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
{
// Here you will get the Control you need like:
DropDownList dl = (DropDownList)e.Row.FindControl("ddlPBXTypeNS");
}
}

That if will only be valid for a DataRow (the actually row with data) and if it's in Edit mode... because you only Edit one row at a time the e.Row.FindControl("ddlPBXTypeNS") will only find the control that you want.

For More Info....

Visit

http://stackoverflow.com/questions/833490/asp-net-3-5-gridview-row-editing-dynamic-binding-to-a-dropdownlist

No comments: