Accessing TextBox/Label controls inside a Repeater control

  • Thread starter Ashish Bandi via .NET 247
  • Start date
A

Ashish Bandi via .NET 247

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.
 
S

Scott Mitchell [MVP]

Ashish said:
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
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top