I want to set the text value of a label that is within a datalist in
the codebehind. Does this have to be done in the databound event?
Simplified example:
<asp:DataList id="dlItem" runat="server">
<ItemTemplate>
<asp:Label ID="lblItemPrice" runat="server" />
</ItemTemplate>
</asp:DataList>
in codebehind:
Label lblPrice = (Label) dlItem.Controls[0].FindControl("lblPrice");
lblPrice.Text = someValue;
I really just want to know how to access the label explicitly.
Basically, the databinding on the datalist is getting values from a
datareader, but the label does not. For layout purposes, however, the
label needs to be nested within the datalist.