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 appr开发者_如何学JAVAoach this?
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.
精彩评论