LinkButton field and FindControl

R

Roberto Kohler

Hi,

I have a LinkButton in a TemplateField inside my GridView
How do I access this control in the RowDataBound handler?

I've tried this:

Dim LinkEdit As LinkButton
If e.Row.RowType = DataControlRowType.DataRow Then
LinkEdit = e.Row.FindControl("LinkEdit")
LinkEdit.CausesValidation="true"
End If

but it I get the error "Object reference not set to an instance of an
object"
 
T

Teemu Keiski

Hi,

that should be somewhat right assuming LinkButton has ID "LinkEdit" and it's
not inside EditItemTemplate (except that if you have it declaratively there,
you might want to set CausesValidation already at that point, in aspx, to
avoid unnecessary state to be kept in ViewState,l when possible)

Can you show how you have declared the TemplateField?
 

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

No members online now.

Forum statistics

Threads
474,135
Messages
2,570,783
Members
47,341
Latest member
hanifree

Latest Threads

Top