Read items into a DataList

A

Alberto

I have a DataList with data retrieved from a data base and, when the user
select an item with a clic, I need read the value of a Label who is in the
Datalist.

Actually I'm trying this:

((System.Web.UI.WebControls.Label)e.Item.FindControl("lblID")).Text

but (I don't know why) I only can modify it but I can't read it.

How can I find out the value of the label?

Thank you very much.
 
J

Janaka

ok try doing this:

Label lblTest = (Label)e.Item.FindControl("lblID");
Trace.Write("Label exists", lblTest == null ? "No" : "Yes");
string id = lblTest.Text;

if you get an error on the third line look at the trace and see whether its
found your Label control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top