Using the TextBox's TextChanged event from inside a DataList

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Sep 19, 2007.

  1. I have a DataList that contains TextBoxes. I want to postback when the
    TextChanged event occurs. I have the TextBox's AutoPostBack property set to
    True, but it does not seem to be doing a postback. I would expect this to
    bubble up to the DataList's ItemCommand event, but this does not seem to be
    happening. I will note that the DataList is inside an UpdatePanel, but it
    should still do the postback. Any ideas why this is not working? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
     
    Nathan Sokalski, Sep 19, 2007
    #1
    1. Advertising

  2. I have found how to get the TextChanged event to fire, using the following
    code:

    Private Sub datCart_ItemCreated(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataListItemEventArgs) Handles datCart.ItemCreated
    AddHandler CType(e.Item.FindControl("txtQuantity"), TextBox).TextChanged,
    AddressOf Me.TextChanged
    End Sub

    However, in the eventhandler I need to know which item the TextBox that
    fired the event came from, otherwise making the TextBox part of the DataList
    is pointless. I need to know either the index or the associated DataKey.
    Events such as ItemCommand allow you to access the ItemIndex using the
    second argument of the event handler. I have figured out how to get access
    to the DataListItem and DataList it came from by using properties of the
    sender argument, but even the DataListItem does not supply me with the
    index. The only solution I can come up with is to add a Hidden field to the
    Template that holds the value I need, but I would prefer not to do this. If
    anybody knows of a more efficient method, please let me know. Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    "Nathan Sokalski" <> wrote in message
    news:eNnX8$k%...
    >I have a DataList that contains TextBoxes. I want to postback when the
    >TextChanged event occurs. I have the TextBox's AutoPostBack property set to
    >True, but it does not seem to be doing a postback. I would expect this to
    >bubble up to the DataList's ItemCommand event, but this does not seem to be
    >happening. I will note that the DataList is inside an UpdatePanel, but it
    >should still do the postback. Any ideas why this is not working? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
     
    Nathan Sokalski, Sep 19, 2007
    #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. jorge
    Replies:
    2
    Views:
    1,339
    jorge
    May 26, 2004
  2. Nathan Sokalski
    Replies:
    1
    Views:
    1,226
    Nathan Sokalski
    Sep 19, 2007
  3. S_K
    Replies:
    6
    Views:
    1,251
    Robert Dunlop
    Nov 8, 2007
  4. jorge
    Replies:
    1
    Views:
    447
    Teemu Keiski
    May 28, 2004
  5. jorge
    Replies:
    0
    Views:
    342
    jorge
    May 25, 2004
Loading...

Share This Page