• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1164
  • Last Modified:

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:

e.Row.Controls(4).FindControl("txtM2Amt_add")

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.

Thanks,

N
0
stretch73
Asked:
stretch73
1 Solution
 
Bob LearnedCommented:
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)

Bob


0
 
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.

Sincerely,

The Learning One
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now