locked
Reference Label inside of Repeater Control RRS feed

  • Question

  • User1377562836 posted

    Hello,

    How do you reference the labels in the header section (_lblMonth01) in the repeater control using csharp?

    Thanks, sckeels

     


    <asp:Repeater id="_rptGraphData" runat="server">
    <HeaderTemplate>
    <table class="tblOutline" border="1" width="600px">
      <tr>
        <th style="width:20%; text-align:center;">Group</th>
        <th style="width:15%; text-align:center;"><asp:Label ID="_lblMonth01" Text="Month 01" runat="server" /></</th>
        <th style="width:15%; text-align:center;"><asp:Label ID="_lblMonth02" Text="Month 02" runat="server" /></</th>
        <th style="width:15%; text-align:center;"><asp:Label ID="_lblMonth03" Text="Month 03" runat="server" /></</th>
        <th style="width:15%; text-align:center;"><asp:Label ID="_lblAct" Text="Act" runat="server" /></</th>
        <th style="width:15%; text-align:center;"><asp:Label ID="_lblTgt" Text="Tgt" runat="server" /></</th>
      </tr>
      </HeaderTemplate>
      <ItemTemplate>
      <tr>
        <td style="width:20%; text-align:left;"><%#Eval("GroupName")%></td>
        <td style="width:15%; text-align:right;"><%#Eval("Month01")%></td>
        <td style="width:15%; text-align:right;"><%#Eval("Month02")%></td>
        <td style="width:15%; text-align:right;"><%#Eval("Month03")%></td>
        <td style="width:15%; text-align:right;"><%#Eval("Act")%></td>
        <td style="width:15%; text-align:right;"><%#Eval("Tgt")%></td>
      </tr>
      </ItemTemplate>
      <FooterTemplate>
      </table>
    </FooterTemplate>
    </asp:Repeater><br />

    Tuesday, October 16, 2007 11:29 AM

Answers

  • User77042963 posted

    OnItemDataBound="repeater1_ItemDataBound"

     protected void repeater1_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                Label myLabel;
                myLabel = (Label)e.Item.FindControl("_lblMonth01");
                myLabel.Text = "This is the label!";
    
            }
    
        } 
    
     

     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 16, 2007 12:33 PM
  • User1377562836 posted

    Thanks limno...

     sckeels

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 17, 2007 9:58 AM

All replies

  • User77042963 posted

    OnItemDataBound="repeater1_ItemDataBound"

     protected void repeater1_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                Label myLabel;
                myLabel = (Label)e.Item.FindControl("_lblMonth01");
                myLabel.Text = "This is the label!";
    
            }
    
        } 
    
     

     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 16, 2007 12:33 PM
  • User1377562836 posted

    Thanks limno...

     sckeels

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 17, 2007 9:58 AM