Click here to Skip to main content
15,036,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to persist all the values of the listbox on page postback in asp.net?

For instance we have a listbox and some values are added into it using javascript, when ever user click on Next Button then validation is performed and the values added into listbox doesnot persist instead all the values are gone. So when ever any validator is fired or if the page postback, all the values with in the listbox must be retained.
Posted
Updated 11-Aug-10 20:55pm
v2

1 solution

some values are added into it using javascript

If you are adding few values client side using Javascript then you need to track it and probably keep it in Hidden field. Next postback or so, re-populate it using the hidden field.

Viewstate wont work here as it works for normal listbox populated on server side. Since you added data on client side, you need to use some extra code to track and update it.
   
Comments
raju melveetilpurayil 12-Aug-10 15:47pm
   
hidden field also get clear after post back.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900