views:

193

answers:

1

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>
A: 

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