Gridview Findcontrol

Posted on 2007-10-12
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,

Question by:stretch73
    LVL 16

    Accepted Solution

    Dim txtM1Amt As String = _


    Author Comment

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now