Tuesday, 5 May 2015

How to avoid RowDataBound when GridView is edited?


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == DataControlRowState.Alternate))
            {
                Label groupID = (Label)e.Row.FindControl("idgroup");
                LinkButton myLink = (LinkButton)e.Row.FindControl("groupLink");
                myLink.Attributes.Add("rel", groupID.Text);
            }
        }
    }

if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
    //In Edit mode
}
if (e.Row.RowState != DataControlRowState.Edit)
{
  // Here logic to apply only on initial DataBinding...
}

No comments:

Post a Comment