Extracting TextBox.Text from within a Datalist

Discussion in 'ASP .Net' started by BisMan, Jan 18, 2008.

  1. BisMan

    BisMan Guest

    I have a datalist called datalist2
    I want to get the text from a textbox called textbox1 which is in the
    ItemTemplate of the datalist.

    In the past I have gotten information out of the create user control in
    the following way:
    ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("StudentID")).Text;
    But the same approach doesn't work with the datalist...
    Please help!?



    --
    BisMan
    ------------------------------------------------------------------------
    Posted via http://www.codecomments.com
    ------------------------------------------------------------------------
    BisMan, Jan 18, 2008
    #1
    1. Advertising

  2. If you are doing it from withing one of the DataList events (such as
    ItemCommand) you can do the following:

    ((TextBox)e.Item.FindControl("StudentID")).Text

    Just like you were before, only you are accessing the current item using one
    of the event arguments

    If you are not working in one of the DataList events, use the following:

    ((TextBox)DataList.Items(item_index).FindControl("StudentID")).Text
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "BisMan" <> wrote in message
    news:...
    >
    > I have a datalist called datalist2
    > I want to get the text from a textbox called textbox1 which is in the
    > ItemTemplate of the datalist.
    >
    > In the past I have gotten information out of the create user control in
    > the following way:
    > ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("StudentID")).Text;
    > But the same approach doesn't work with the datalist...
    > Please help!?
    >
    >
    >
    > --
    > BisMan
    > ------------------------------------------------------------------------
    > Posted via http://www.codecomments.com
    > ------------------------------------------------------------------------
    >
    Nathan Sokalski, Jan 19, 2008
    #2
    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,846
  2. KatB
    Replies:
    0
    Views:
    431
  3. mintboy
    Replies:
    0
    Views:
    733
    mintboy
    Jan 24, 2006
  4. BisMan
    Replies:
    0
    Views:
    354
    BisMan
    Jan 19, 2008
  5. Will

    Problem with DataList within DataList

    Will, Oct 10, 2007, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    180
    Walter Wang [MSFT]
    Oct 18, 2007
Loading...

Share This Page