How to get data from a BulletedList in CodeBehind ASP.NET?

2

I have a list of items set through a BulletedList in an Asp.net page. This list is populated with multiple items through the DataSource , DataTextField , DataValueField , and DataBind() attributes in CodeBehind in C #.

I need the user to reorder the items in this list, and then the page can save this new sorted list instead of the old list. For this, I implemented the jQuery Sortable, following these two links: [1] and [2] .

So far so good, everything is working normally. But at the time of saving, I need to get that list back (more precisely, the values of DataValueField ) to save the changes, and this is my question: How could I get those values back in CodeBehind?

Note: for some reason I do not have access to GetData() and GetDataSource() methods, which could help with this.

    
asked by anonymous 16.04.2014 / 01:05

1 answer

1

You can use the property Items , it will get something like

for (int i=0; i<BULLETEDLIST.Items.Count; i++) {
         if (BULLETEDLIST.Items[i].Selected)
            RETURN;
      }

Instead of return you put the logic of your code, you can create an array and save in that array the items according to current positions.

    
17.04.2014 / 16:27