views:

320

answers:

1

I've got an administrative page with a listbox filled with values. A user can also change the order of the values via some jquery, and in theory we'll save that order and it will change the order of display in a listbox in some other, exotic, locale.

The jquery works fine. When the user saves I use this code to process the listbox:

index = 0;
foreach (ListItem item in lstProspectStatus.Items)
{
     //Save that particular item's data, using index as the value for the   
     //display sequence field.

     index++;
}

The problem is, the Items collection is returning the order the items where in when the control was populated. The client-side order change is ignored.

What is the best way for me to approach this?

+4  A: 

I would stash the new order into a hidden field, and then read from that on the server side.

The problem you're getting is that the sequence of those elements is getting reset by ASP.NET when the system rebuilds the dropdownlist during the postback cycle.

Stephen Wrighton
Yeah, that's the best bet. Not really hard to do either. Thanks!
peacedog