GridView FindControl

Posted on 2007-10-17
Last Modified: 2013-11-26
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.


Question by:stretch73
    LVL 96

    Accepted Solution

    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)



    Author Comment

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    737 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

    19 Experts available now in Live!

    Get 1:1 Help Now