GridView FindControl

I have a gridview that contains a number of textboxes in an edit template.  I'm using the following to manipulate the textboxes:


It works, but I don't understand how.  I copied the code from another page and figured I'd get an error from not changing the '4'.  What exactly are you supposed to specify in the control index in order to reference the control.


Who is Participating?
Bob LearnedConnect With a Mentor Commented:
You got lucky I guess.  The simpler method for FindControl is from the GridViewRow:

Dim txtM2Amt_add As TextBox = CType(e.Row.FindControl("txtM2Amt_add"), TextBox)


stretch73Author Commented:
Hey Bob,

Yup, that works.  I think having the index number of the control is a throwback to v1.1 or something.  You really are the Learned One.


The Learning One
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.