First you have to check and compare RowIndexwith the GridView EditIndexyou need to edit, and put all the code associated with the dropdown menu inside.
In addition, to search for a drop-down list in the footer, you need to use the condition:
if (e.Row.RowType == DataControlRowType.Footer)
And to search the list in the line use
if (e.Row.RowType == DataControlRowType.DataRow)
RowDataBound GridView.
:
protected void MyGridView_RowDataBound( object sender, GridViewRowEventArgs e)
{
if(MyGridView.EditIndex == e.Row.RowIndex )
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlRole = (DropDownList)e.Row.FindControl("ddlRole");
}
if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList ddlFRRole = (DropDownList)e.Row.FindControl("ddlFRRole");
}
}
- :
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
:: if (e.Row.RowState == DataControlRowState.Edit)