Last post Apr 24, 2011 12:49 PM by Shellymn
Apr 17, 2011 10:14 AM|techie4aspnet|LINK
Hi, I have a drop down in aspx page , i want to disable view state of that drop down with out affecting dropdownselected event .
reason of disabling view state of dropdown is because it loads thousands of options which makes that page heavy..
Any help appreciated
Apr 17, 2011 12:57 PM|V.Karthikeyan|LINK
You can always enable or disable Viewstate at every control level. You just need to set
EnableViewState="false " or ViewStateMode="Disabled" in that dropdown
<asp:DropDownList ID="dropdown" runat="server" EnableViewState="false" ViewStateMode="Disabled"></asp:DropDownList>
Apr 18, 2011 04:52 AM|sandy060583|LINK
I would suggest you to cache DDL rather than disabling viewstate of it. becoz disabling viewstate might cause problem when you try to access values in it during postback. Hope this will help !!!
Apr 18, 2011 04:12 PM|budugu|LINK
I have a drop down in aspx page , i want to disable view state of that drop down with out affecting dropdownselected event .
SelectedIndexChanged event will fire, even if you disable the Dropdown viewstate.
But the event is meant to fire whenever the index changes and theres a postback. Since you have viewstate off, the event will fire on
each postback.(on Button click etc..)
Apr 19, 2011 02:09 AM|sirdneo|LINK
Disabling viewstate will not effect any of the events however after every postback, you have to re-bind the dropdown with datasource.
I recommend you that if you are populating dropdown with thousands of records why don't you try replacing it with autocomplete textbox. They are quite fast in terms of speed and page size. Here are some samples:-
Apr 24, 2011 12:49 PM|Shellymn|LINK
make enable view state property of dropdownlist to false. if you do this
1) the selection made by the user will not retained.
2) need to bind data source every time page loads.
work around for this declare a hidden variable and set the selected value by user using JS ,then on the page load check for any value change, if
value changed then call dropdown selected index change event explicitly
Hope this helps