Click to See Complete Forum and Search --> : Postbacked properties in ASP.NET
Babak
02-06-2003, 10:42 AM
I have some long drop down lists that can be filled on the server easily, so I dont want a long view state and data transfer. but I want to have the selected item on the lists.
if I set EnableViewState=false I don't get the selected item and if I set it to true I get all the items in the lists as well.
Any suggestion appriciated
sdonato
02-06-2003, 10:44 AM
i am not that good in .net but i think i understand what you need if you post the query your working with i maybe able to help.
-sdonato
Babak
02-06-2003, 10:56 AM
To educate you on what ASP.NET does
ASP.NET doesnt need any action to transfer form data to server like QueryString,...
It does it automatically using a text in the header part of html form called ViewState which contains the value of all properties of all controls on the form.
It also supports the old methods of ASP, but I don't want to use them.
I fill the drop down lists using code without refering to a database. ( for example 1..31 for days of a month)
I hope these info gives you an idea
thanks
Ribeyed
02-06-2003, 11:33 AM
hi,
i am fairly new at .NET myself but i do have a few ASP.NET books at hand. You are trying to use ViewState to preserve the information on post back correct?
if so are your list boxes ASP.NET controls e.g. you have
id="mylabel" and Runat="Server"
Try viewing the source to make sure that the hidden form field is present. Should look something like this:
<input type="hidden" name="_VIEWSTATE" value="YTBJGLHJDU75892KOoejk0JKM................./>
This will show you all preserved informaion that the user previously entered.
By default almost all ASP.NET controls retain the values of their properties between form posts.
Form controls, such as TextBox and RadioButtonList, retain their values between posts even when view state is disbaled. The values of these controls do not need to be preserved in the _VIEWSTATE hidden form field because they ae actually being submitted to the server on each form post.
Hope this helps, if not post some code mabe we will be able to spot a problem.
Babak
02-06-2003, 12:08 PM
Unfortunately as I turn off EnableViewList for my drop down it's ddl1.selectedItem is nothing in posted back page.
ASP.net sends all the Items in all drop downs ( as I add more data to my drop down , ViewState gets larger)
If it sends the selected item back as EnableViewState is False how can access it?
Thanks
Ribeyed
02-06-2003, 04:56 PM
hi,
ASP.net sends all the Items in all drop downs
This doesn't seem normal behaviour. By this i think you're saying that all the items selected or not, in all the list menus are being posted back. If you can post the code maybe we can spot something else that maybe causing this to happen.