Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
|
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 9th, 2003, 04:20 AM
Registered User
 
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with SelectedIndexChanged not firing

Hello, I have a few issues but this one is stopping me in my tracks.
I am making a asp.net app using VB, and I have some basic controls on my web form: drop down list box, button, label. Now when I double click on the drop down box and I get the SelectedIndexChanged event and fill it in with some basic code, when I run the app that event doesnt even get ran. Now I have a web form button and web form drop down box. Also the button command and text values are Submit.

Also I am trying to store what value was selected in the drop down box and carry it over to the postback page so I can do other means with that value, but I am unable to save it using ViewState() function. Well am unsure if its saving the value but getting the value out of it could be failing also. I cant debug it since the server isnt setup to do it, so I kinda have to use the lable to send output text.

Also another problem, in my button event I have this code
ViewState.Add("INDEX", 1)

in my load event I got this code
If IsPostBack = True Then
   Label1.Text = CType(ViewState("INDEX"), String)
end if

The value isnt being sent over, and those 2 lines dealing with ViewState are the only code related to that, also I have enableviewstate for the button and drop down to true. I am not making a new viewstate obj which I dont think I need to myself. But anyway the code isnt working so if there are any settings that I need for this to work let me know.

Thank you.
 
Old December 9th, 2003, 10:27 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

First off, you shouldn't need to do save a value from a control in viewstate. The controls save their own values in viewstate already. You don't need to use viewstate if you have everything set up correctly.

How are you populating the DDL? This has significant bearing on the problem depending on how the DDL is getting populated. If your are databinding the DDL then the problem may be very easy to solve. Typically, people will databind a DDL but not make it conditional based on "IsPostback". This results in the DDL being re-bound every time the page is loaded. The process of binding the control causes the viewstate information (i.e., what the previous value was) to get lost so the framework has no way of knowing that the value has changed.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 9th, 2003, 02:29 PM
Registered User
 
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How I am populating the DDL is I have a function that opens an xml file and gets the values that I want then closes it and each time I have the right value I will add it to the list.

The reason why I am trying to use viewstate is because all my values are going away and I need to reread that xml file to pop the DDL again, but it defaults to 0 index, which means to me its because of the repop. By this point I dont know what value was selected after I clicked the button.

Also if I select a value from the list then click the button it doesnt get the value I selected so I can use it but rather defaults to 0 even if I selected index 1.





Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdownlist on selectedindexchanged RoniR ASP.NET 1.x and 2.0 Application Design 4 April 6th, 2012 04:50 PM
selectedindexchanged event not firing kaliaparijat ASP.NET 2.0 Professional 1 June 5th, 2008 08:58 AM
Problem with Dropdownlist.SelectedIndexChanged haydar BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 0 July 20th, 2007 10:26 AM
SelectedIndexChanged & Databinding problems blakemi4 Visual Basic 2005 Basics 0 August 1st, 2006 08:55 AM
SelectedIndexChanged venterjo General .NET 7 December 15th, 2004 09:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.