Accessing TextBox/Label controls inside a Repeater control

Discussion in 'ASP .Net Web Controls' started by Ashish Bandi via .NET 247, May 14, 2004.

  1. Hi all,

    I am looking for some help on Reapeter control.

    My repeater control has a textbox and label control in the itemtemplate. How can i access the values of these controls (textbox and label) in the body of the DisplayRepeater event handler (handling RepeaterItemEventArgs) ..

    <asp:repeater id="myRepeater" runat="server" OnItemDataBound="DisplayRepeater">
    <itemtemplate>
    <asp:TextBox ID="rptxtQuantity" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>'></asp:TextBox>
    <asp:Label ID=rplblPrice runat=server></asp:Label>
    </itemtemplate>

    <alternatingitemtemplate>
    // what should go here
    </alternatingitemtemplate>

    <footertemplate>

    </footertemplate>


    Also, if I place the same controls in the alternatingitemtemplate (change the background color etc.), it creates a name conflict. How to avoid that.

    Thanks for your help in advance.
    --------------------------------
    From: Ashish.

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>gYmceSzwI0WstI8Nf5PJIg==</Id>
     
    Ashish Bandi via .NET 247, May 14, 2004
    #1
    1. Advertising

  2. Ashish Bandi via .NET 247 wrote:
    > My repeater control has a textbox and label control in the itemtemplate. How can i access the values of these controls (textbox and label) in the body of the DisplayRepeater event handler (handling RepeaterItemEventArgs) ..
    >
    > <asp:repeater id="myRepeater" runat="server" OnItemDataBound="DisplayRepeater">
    > <itemtemplate>
    > <asp:TextBox ID="rptxtQuantity" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>'></asp:TextBox>
    > <asp:Label ID=rplblPrice runat=server></asp:Label>
    > </itemtemplate>


    Use FindControl(). More information available at this FAQ:
    http://datawebcontrols.com/faqs/ProgrammaticAccess/AccessingTemplateColumnContents.shtml

    Happy Programming!

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

    * When you think ASP, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], May 14, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    1
    Views:
    491
  2. John Kotuby
    Replies:
    4
    Views:
    408
    John Kotuby
    Feb 27, 2007
  3. HockeyFan
    Replies:
    1
    Views:
    1,029
    Masudur
    Jul 4, 2007
  4. Kiran More
    Replies:
    2
    Views:
    339
    Kiran More
    Nov 14, 2006
  5. Knut Krueger
    Replies:
    8
    Views:
    324
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page