How do I access the HTMLTableRowCollection ?

Posted on 2004-11-18
Last Modified: 2012-06-21
How do I access the HTMLTableRowCollection when in the code behind of an ASP page ?

I have the page as :

<TABLE id="tbl1" cellSpacing="0" cellPadding="0" align="center" border="0">
    <TR id="tr1" align="left">
        <TD align="left">
            <asp:TextBox id="Textbox1" tabIndex="24" runat="server" Columns="32" MaxLength="20"></asp:TextBox>

In the code :

protected System.Web.UI.HtmlControls.HtmlTableRow tr1;

this.tr1.Visible = true;

But the tr1 object is not set to an instance of the object.

I can see that tr1 is undefined but how to a set it to the instance on the page ?

Question by:Paul__M
    LVL 1

    Accepted Solution

    You probably have to set them as 'runat=server' to view them in your CodeBehind-Class.
    The aspx derives the codebehind-class not otherwise so you have to declare it this way and your IDE will declare it also in the codebehind-class (if not you can do it yourself).
    With an tag declared as runat=server this object is recognized as derived from the underlying codebehind-class (or some parent of it).


    Author Comment

    Just realised that myself - thanks.

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    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…

    755 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

    25 Experts available now in Live!

    Get 1:1 Help Now