net 4 and c#.
I have a GridView, I would like take a Row when in Edit Mode in my code and find a control.
Here my code, but does not work, it takes only the first row for the GridView.
Any ideas?
protected void uxManageSlotsDisplayer_RowDataBound(object sender, GridViewRowEventArgs e)
{
switch (e.Row.RowType)
{
case DataControlRowType.DataRow:
// Take Row in Edit Mode DOES NOT WORK PROEPRLY
if (e.RowState == DataControlRowState.Edit)
{
Label myTest = (Label)e.Row.FindControl("uxTest");
}
break;
}
MY CODE EXAMPLES: GridView row in edit mode
SOLUTIONS: After reading this: Gridview row editing - dynamic binding to a DropDownList
protected void uxList_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:
Label dl = (Label)e.Row.FindControl("uxLblTest");
dl.Text = "xxxxxxxxxxxxx";
}
}