GridView RowDataBound -- EditItemTemplate vs. ItemTemplate

  • Thread starter Thread starter K B
  • Start date Start date
K

K B

Hi, I'm using the following to change a text label in a specific
row/control. This works great until I click the Edit commandfield. then
RowDataBound can't find the Label control because it is now a Textbox.
How do I indicate the using this code ONLY in ItemTemplate mode?

If e.Row.RowType = DataControlRowType.DataRow Then
Dim lbl As Label = CType(e.Row.FindControl("UserName"), Label)
If lbl.Text = "" Then 'should be blank in only one row

Thanks!
KB
 
If e.Row.RowType = DataControlRowType.DataRow And _
e.Row.RowState=DataControlRowState.Alternate Or _
e.Row.RowState=DataControlRowState.Normal Then
 
Back
Top