problem with control in Repeter control???

Discussion in 'ASP.NET / ASP.NET Core' started by cool_man77, Aug 22, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have put the label control(myLabel) in the list control(myRepeter)

    <asp:Repeater id="myRepeter" runat="server">
    <ItemTemplate>
    <asp:label id="myLabel" runat="server"/><%# Container.DataItem("Item") %>
    </ItemTemplate>
    </asp:Repeater>

    I want to access to "myLabel" properties like: Text, BackColor.. in Page_Load sub. I had use:

    Sub Page_Load(s as Object, e as EventArgs)
    myLabel.Text = "Hello"
    End Sub

    But I receive error "Name 'myLabel' is not declared."

    Can anyone help me to solve this problem, please?

    Thanks!
     
  2. Try using the ItemDataBound method of the repeater as each item is bound you can access it's control(s).

    e.item.controls(1) it will return the label control in your example



    Matt G.
    NMyVision.com
    Developer / Designer
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page