0

I am trying to use a label in my datarepeater, when I am able to bind data and write to me html page.

<asp:Label ID="lblID" runat="server"><%# DataBinder.Eval(Container.DataItem, "ID")%></asp:Label>

which works fine.

When I try to get text value I get "".

Label lblcurrentID = ri.FindControl("lblID") as Label;

result: lblcurrentID.text = ""

this same code works fine for the dropdownlist that I have in the datarepeater. I am wondering if this has anything to do with the label being converted to a span tag.

<span id="template6_middlecontent1mAzoaNominationApproval0_dataReaper_ctl01_lblID">2009040100000888213</span>
Dedrick
  • 187
  • 1
  • 11

2 Answers2

0

you need bind lblD.Text with the value not like

<%# DataBinder.Eval(Container.DataItem, "ID")%>

Laxmikant
  • 588
  • 4
  • 11
0

I've ran into this issue before, I don't recall actually finding a solution to the problem, as a work around, I used an <asp:HiddenField> to hold onto the information for me:

<asp:HiddenField runat="server" id="hiddenId" value='<%# Eval("Id") %>' />

Note the ' instead of " wrapping the Eval statement btw, .NET is fussy when you're assigning values to server controls.

Kirschstein
  • 14,570
  • 14
  • 61
  • 79