tags:

views:

43

answers:

2

I have a dropdown and 2 listboxs in a updated panel and a save button on the page. When the page loads I load one of the list boxes with data related to the selected dropdown item. When the user selects a different item in the drop down I do a postback and reload the listbox with data related to the selected item. When the user clicks save on the page the listbox.Items are the orginal items loaded with the first page load and the items that are showing on the page.

Any ideas how to fix this?

A: 

Make sure you dont bind the data on every postback. Use Page.IsPostback to check this.

alexn
I'm already doing that. One other thing. If I load the listbox from the other listbox via javascript it all works fine.
Don
Also if I take out the update pannel it all works fine.
Don
A: 

To fix this problem I had to update the viewstate from the client side. Below is the javascript function I called once the postback of the update panel is completed:

function UpdateStateforList(list){

var i;
var state = "1";
for(i = 0; i < list.options.length; i++){
 state += "|" + list.options[i].text + "|" + list.options[i].value;
}
eval("document.forms[0]." + list.id + "_State.value = state");

}

Don