Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Using the TextBox's TextChanged event from inside a DataList

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Sokalski - 19 Sep 2007 00:59 GMT
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.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

Nathan Sokalski - 19 Sep 2007 02:39 GMT
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.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

>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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.