Read items into a DataList

  • Thread starter Thread starter Alberto
  • Start date Start date
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.
 
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.
 
Back
Top