We help IT Professionals succeed at work.

Gridview Findcontrol

stretch73 asked
Last Modified: 2013-11-26
I'm using the following code to find a textbox:

txtM1Amt = e.Row.Controls(4).FindControl("txtM1Amt_add")

I inherited this application and I'm just curious as to how it works.  I follow that the row has a controls collection but I don't understand what controls are included.  If the user clicks "Edit" on this row and it brings up the update and cancel buttons, how does that affect the count of the controls.  I have this same code in the footer row and it works fine, not the case in the actual grid.

Thanks in advance,

Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)


I'm adding a javascript to the control like this:

txtM1Amt.Attributes.Add("onkeypress", "return isNumberKey(event);")

It has more to do with making sure I get the correct control than the data inside of it
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.