0

Can some one tell me how I can move items up and down in a GridView control? I've found a good example here, but I'm using a LINQ data source and I'm not sure how to achieve it this way?

Can anybody help me?

Jimmy Collins
  • 3,294
  • 5
  • 39
  • 57
  • It would help to post your code so that we know how you are going to do it, ie with the selected item on the grid, a command button on the current row etc. – TBohnen.jnr Apr 28 '11 at 10:56

2 Answers2

1

The GridView control renders an HTML table, so I would suggest the best way to manipulate that data would be client side using jQuery. That way you're not reloading the page, simply manipulating the DOM.

Take a look at this answer for an example:

How to move table row in jQuery?

This is of course assuming you're talking about just the way the data is represented in the browser, and not editing the database fields.

Community
  • 1
  • 1
Ira Rainey
  • 5,173
  • 2
  • 34
  • 42
  • No probs. And if you want to implement client side sorting then take a look at the jQuery table sorter plugin: http://tablesorter.com – Ira Rainey Apr 28 '11 at 11:47
1

When you want to have an order for the items then you have to have an Order property in the record.

If you have it then it'll be easy by just swaping between the item's order with the previous one in case of MoveUp and with the next one in case of MoveDown.

And then finally rebind the grid.

Homam
  • 23,263
  • 32
  • 111
  • 187