views:

36

answers:

2

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

+1  A: 

Can you try declaring your label like this:

<asp:label id="weiLabel" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.weiLabel")%>' / >
Abe Miessler
Thanks! Nice catch.
A: 

You can also try putting in the value into your label from the code behind using the databound method. I find it a bit easier to debug and cleaner then putting it in the html

 Private Sub repPoliList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repPoliList.ItemDataBound

    If (e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem) Then

        Dim dr As DataRowView = CType(e.Row.DataItem, DataRowView)

        Dim weiLabel As System.Web.UI.WebControls.Label= CType(e.Item.FindControl("weiLabel"), System.Web.UI.WebControls.Label)
        weiLabel.text= dr("ColumnFromDatabase"


    End If

End Sub
Lareau