Read items into a DataList

Discussion in 'ASP .Net' started by Alberto, Oct 24, 2003.

  1. Alberto

    Alberto Guest

    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.
     
    Alberto, Oct 24, 2003
    #1
    1. Advertising

  2. Alberto

    Janaka Guest

    What event is being raised when you click an item?

    "Alberto" <> wrote in message
    news:%...
    > 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.
    >
    >
     
    Janaka, Oct 24, 2003
    #2
    1. Advertising

  3. Alberto

    Alberto Guest

    I'm writing the code in the ItemCommand event of the DataList.

    "Janaka" <> escribió en el mensaje
    news:u10o$...
    > What event is being raised when you click an item?
    >
    > "Alberto" <> wrote in message
    > news:%...
    > > 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.
    > >
    > >

    >
    >
     
    Alberto, Oct 24, 2003
    #3
  4. Alberto

    Janaka Guest

    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.

    "Alberto" <> wrote in message
    news:u$...
    > I'm writing the code in the ItemCommand event of the DataList.
    >
    > "Janaka" <> escribió en el mensaje
    > news:u10o$...
    > > What event is being raised when you click an item?
    > >
    > > "Alberto" <> wrote in message
    > > news:%...
    > > > 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.
    > > >
    > > >

    > >
    > >

    >
    >
     
    Janaka, Oct 24, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nevyn Twyll
    Replies:
    8
    Views:
    1,940
  2. Gilles Kuhn
    Replies:
    0
    Views:
    451
    Gilles Kuhn
    Sep 15, 2003
  3. lokb
    Replies:
    5
    Views:
    4,685
    Victor Bazarov
    Jul 8, 2004
  4. Bart Van Hemelen
    Replies:
    2
    Views:
    4,703
    Bart Van Hemelen
    Sep 4, 2006
  5. ela
    Replies:
    12
    Views:
    372
    Uri Guttman
    Apr 6, 2009
Loading...

Share This Page