View state and loading drop down on post back.

The page contains 6 drop downs with many values resulting in very big view state. So I disabled view state of all drop down and filled drop down on every post back.

Now the problem is as view state is disabled and drop downs are being filled on each post back, they are not retaining their selected value on post back. Also filling drop down on page load method is resulting in overrating selected value and getting always 0 as selected value in button click event.

Do I need to make view state enabled here?

7/13/2005 8:19:03 AM 91979 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 46


yes, you need to enable the view state.

Each DropDownList in your page is reinstantiated every time the page is loaded. So, retaining a state is the only way you have to persist values across multiple requests. This is the main purpose of the ViewState.

More precisely, the role of ViewState is to persist  *changes* across multiple requests for a page, and selecting a value in a DropDownList is an example of such change.

If you fill each DropDownList on postbacks, you are rebuilding its items from scratch, and thus restoring their properties.

Alessandro Gallo | Blog | My book: ASP.NET AJAX In Action
7/13/2005 9:23:53 AM


You don't need to enable view state. You are binding the data to DropDownList in page load event . Instead of binding the data in Page load event , bind it in page OnInit event.

and it will work fine.


Hope this will help u.



11/8/2008 6:05:44 PM

Similar Artilces:

Drop Drop filled with AJAX Web Service Getting empty on Post Back.
Hi I am filling a Drop Down Control using AJAX WebService but i am facing a issue.  Issue: Drop Down is getting filed propery with the AJAX WebService and JavaScript Code. But now when the page is getting loaded after a postback, the contents of the drop down are getting lost. For Eg: I have a Drop Down and a button. The Drop Down is filled with AJAX WebService Code and on Button Click the page is doing postback and again  page is displayed. Now when the page loads back, the drop down which was filled with Ajax is empty.  I tried few things but was not able to identify wh...

Getting Failed to load View state error when redirect a page with dynamic tree view
Hi,I am getting a "Failed to load viewstate" error when ever I redirect a page with dynamic treeview. Here are the details. I am using master page. I have a user control 1 that has a database driven tree view. I call (register) this user control 1 in the master page in content place holder 1 and I have another user control 2 with a gridview control. I call this   user control 2 in the master page in the content place holder2. The gridview has Footer with Insert button. When ever I click on a insert button on the gridview it does pos...

how to save the View state and post back of ...
How to save the View state and post back of control added to TableCell.I adding the  control to the TableCell and lose the data, the checked not checked and other things.any one know how to handle the TableCell to not lose the controls in it (property)?Ido Yahalomi,.NET Architect What exactly are you trying to do. Can you be more explicable?Shravan Addaypally MCP...

Preserve View State value at post back
Hi All,    I am creating a custom server control.That control contains a check box list. For the first time I am getting value for that check box list, at run time through Get/Set property. In Property I am using View state for setting value. While page is post back, the view state is getting null. How can I preserve the value of view state. Sample code is as follows,  private CheckBoxList _chkList;protected override void CreateChildControls() {string strItems; string[] StrArrItem = null;char cSplitChar = ','; int intLegth = 0;_chkList = new CheckBoxList(...

How to retain and get the selected value of the drop down upon post back
Hi I have a form view. Inside the formview I have a drop down. I did not bind the drop down with the ODS. Instead I do it manually on the code behind. If the user selects a value I display a textbox beside the drop down and allow the user to enter the value. Upon onblur event of the textbox I do a postback and in the page load i check whethere the page has been posted. If so I add this value to the datatable and once again bind it to the combo box and set the selected value to the text box value.    If the user clicks the save button and when I look for the selected value it says...

what data is stored of DropDownList control form view state when post back?
hello! As we know , the view state is not responsible for having TextBoxes, CheckBoxes, DropDownLists, and other Web controls remember their values across postback. When I dynamically add a DropDownList in the web,and dynamically add the items in it. such as: void Page_Load(Object sender, EventArgs e){   DropDownList ddlDynamic = new DropDownList();   ddlDynamic.ID = "ddlDynamic";    form1.Controls.Add(ddlDynamic);    if (!IsPostBack)   { for (int i=1; i <=3; i++)  ddlDynamic.Items.Add(new ListItem(i.ToStrin...

Can we reserver view state when page is post back from another page
When a page is post back by itself, the view state will automatically be saved and read. But is the page is post to another page, and then call back by that page, can we reserve the state ?  ad_flying wrote: When a page is post back by itself, the view state will automatically be saved and read. But is the page is post to another page, and then call back by that page, can we reserve the state ? I don't think so, whats the purpose for that?Richard XinMCAD(charter member),MCDBA,MCSDWeb Site: (For ASP.Net tips and Code snippet) I have seen this implementation a...

Wizard steps via Mulitple Dynamic Loaded Controls and State on Post back
I have an aspx page that acts as a wizard page with various steps. Each step is a different dynamically loaded control. The control has text boxes and click events that the calling aspx page gets via properties set in the control in the click event. On the second step's post back, the click event isn't firing - seems to be a state problem. The fix I found is to dynamically load every control on every visit to the page but this seems wrong because then why should I load the control dynamically if I have to load all the controls on each visit to the page. Execution goes something like: ...

getting focus back to the same control after post back
Hi friends!  How the control can be set focused on the same conrol after post back from where it was generated?thanks At the event of the control which causes Postback , add {        ControlID.Focus() } in this wayprotected void Page_Load(object sender, EventArgs e) {if (IsPostBack) {Control control = null; string ctrlname = Page.Request.Params["__EVENTTARGET"];if (ctrlname != null && ctrlname != String.Empty) { control = Page.FindControl(ctrlname); control.Focus(); } }   }   Note this will work for all...

Hi, I'm at a loss to explain this... I have an ASPX page that I can't always navigate to. When I developed the app (it's Starter Kit Portal-based), I did it on my LAN and have had no trouble accessing the page. However, upon deployment, I see the following behavior: 1. POST request goes out looking for MyForm.aspx 2. GET request for MyForm.aspx 3. GET request for MyForm.aspx 4. ... X. GET request Sometimes, the page finally loads. Other times, it just ends up blank. Many times, it doesn't load at ALL the first POST - I just get a "The pa...

how to get focus back to the scroll position on post back
I have a long page.  I want the focus to the same position when user do the postback. I tried with MaintainScrollPositionOnPostback="true"  but it is not working. I read that the smartnavigation property is no longer available in 2.0. I have the application with master page. Unless you've defined a separate region within your page, it should work.  See the following for similar discussion.

Question on Post back. Post back to WHAT???
   Hello I am learning about I know that Postback refers to a page being submitted to the web server. But, what is meant when a pages "Posts back to itself" ??? Is this the same thing as the single word Post Back. I ask this, because from what I have read, View State works only if a page "Posts back to itself". Does this terminology refering to a single post back to the server, or a round trip. Please help.     When a page does a PostBack, it basically does a form submit back to itself. All controls/variables are re-instantiated, and then re-populated from...

back ground color is not loaded every time on post back.
I have a menu as a usercontrol which have background color and some text styling. I have learned that some time on post back the color is not appearing but the text seems to allways do it. Why is that? And how do I work around it. My style sheet contains: .infTable_Header{ BACKGROUND: #96b6cc; width: 100%; } ..infTableTd1_Header { vertical-align: baseline; margin:0; padding:0; font-size:25pt; width: 350px; } ..infTableTd2_Header { vertical-align: baseline; margin:0; padding:0; font:italic; font-size:20pt; width:300px; } This refers to a table in...

Getting things back in Start Page and things out of Start Page
I know I posted over a year ago about this same question, I can not find my original post though. I know I posted it and I did find the solution and posted the sollution but I can not find it anywhere here again. They really need a better search engine on these forums. Is there any tools out there to help manage the start page? For example. I have projects that are on a web server I access them on the remote server. Well the start page never ever shows any updates for it the date posted as last access is the day I created it, However this is one of my more used projects. This one is so b...

Web resources about - View state and loading drop down on post back. -

Breech-loading weapon - Wikipedia, the free encyclopedia
A breech-loading weapon is a firearm in which the cartridge or shell is inserted or loaded into a chamber integral to the rear portion of a barrel ...

Facebook Adds Mobile Reach Data To Insights, Cuts Back Loading Of Organic Stories
Facebook announced two changes to its insights Tuesday: the inclusion of mobile reach data, and the lowering of the number of organic stories ...

Facebook’s Fast-Loading and Free “0″ Mobile Site Launches
More than a quarter of Facebook’s users are accessing it through mobile devices every month, and the number of mobile useres is growing fast. ...

Search Twitter - witcher 3 loading
... Learn more here Search Refresh Robb @ The_politician0 23m @XboxSupport brought the witcher 3 from xbox store. Suffering infinite loading screen. ...

Gmail : Why does "?shva=1" get appended to the URL when loading Gmail?
Answer: "shva" is an acronym for "should have valid authentication"

Loading Google Latitude For iPhone - Flickr - Photo Sharing!
Details at

Mike Brown Shooting, Ferguson Missouri! Loading the body in a SUV - YouTube -Another man was shot in St. louis Video by LACN Ferguson police shot and killed Mike Brown of ferguson. ...

Lockyer Valley investors cop 20 per cent rates loading
Lockyer Valley property investors will see a 20 per cent loading applied to their rates bills this financial year in a huge hit to some ratepayers. ...

Penalty rates: Loadings for working weekends and holidays could be over
This could be the last Christmas millions of Australian workers will claim penalty rates for working on weekends and public holidays, unions ...

Google announces service to speed loading of news articles
Google shows off initiative to ensure news articles load more quickly on the web, but one name was conspicuously absent from the presentation. ...

Resources last updated: 2/12/2016 10:28:20 PM