Search code examples
asp.nettextlabelrepeaterfindcontrol

Unable get Label.text in ASP.Net Repeater using FindControl


I can access the text within a textbox within my repeater, but I am unable to pull the text value from a label within my repeater. The repeater is populated from a datatable with row(x) being filled by sqlreader(x), I don't know if that makes a difference. I cannot use javascript for this. I need to access the label value from the codebehind.

<asp:label id="weiLabel" runat="server">
  <%#DataBinder.Eval(Container, "DataItem.weiLabel")%>
</asp:label>

is the markup

I can access a textbox on the same row using:

featTable.Controls(1).Controls(1).FindControl("costText") 

and retrieve the textbox.text, but using the same statement for the label gives me {text=""}.

I have verified that the clientID of control that is returned with findcontrol is correct (featTable__ctl1_weiLabel)

Thanks for any help


Solution

  • Can you try declaring your label like this:

    <asp:label id="weiLabel" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.weiLabel")%>' / >