Saving records that a users has in a specific order?

  • Thread starter Thread starter Brian Mitchell
  • Start date Start date
B

Brian Mitchell

I am trying to save items from a datagrid to a database, but I want to give
the user control over the order of items.



For example if I have a grid with the items:



First

Second

Third

Fourth

Fifth



I would like for them to be able to arrange them in any order and I have
that part figured out on the grid. My problem comes when I want to save the
data to the database. What is the best approach for saving the order the
users has left it in so when they are returned they are still in the correct
order?



Originally I was going to put an 'order' field in the database and simply
order them 1, 2, 3, ..etc but what would happen the user modifies the order
at a later date, would I have to renumber all the items?



I am just looking for the best approach and you all are the experts so any
opinions would be appreciated.



Thanks!!!

Brian
 
Yes, you have to have a field that keep track of the order, and as the user
re-orders items you have to renumber. You don't need to renumber everything,
if there is just a move up/move down functionality, you only need to change
the sequence in the 2 rows being swapped.
 
Brian,

In Net 2.0 I would probably just add another column in the database in which
is the sequence. If you want to make that visible or not is your sake.

Than you can use the dataview, using the Dataview.ToTable (Net 2.0) and than
number the table looping through that and than update that.

Just a thought to try,

Cor
 
Back
Top