GridView RowDataBound -- EditItemTemplate vs. ItemTemplate

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
 
R

Riki

If e.Row.RowType = DataControlRowType.DataRow And _
e.Row.RowState=DataControlRowState.Alternate Or _
e.Row.RowState=DataControlRowState.Normal Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,056
Messages
2,570,440
Members
47,101
Latest member
DoloresHol

Latest Threads

Top