I currently have the following code in a RowDataBound:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Label groupID = (Label)e.Row.FindControl("idgroup"); LinkButton myLink = (LinkButton)e.Row.FindControl("groupLink"); myLink.Attributes.Add("rel", groupID.Text); } }
However, when I click the "Edit" link, it tries to run this code and gives an error. Therefore, how can I run this code ONLY when the GridView is in read mode? But not when editing ...
source share