Home All Groups Group Topic Archive Search About

Saving records that a users has in a specific order?

Author
6 Jan 2006 5:37 PM
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

Author
6 Jan 2006 5:42 PM
Marina
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.

Show quote
"Brian Mitchell" <Magella***@hotmail.com> wrote in message
news:ueURPfuEGHA.312@TK2MSFTNGP09.phx.gbl...
>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
>
>
>
>
>
>
Author
6 Jan 2006 6:07 PM
Brian Mitchell
That's what I figgured. Thanks for the quick reply!!!



Show quote
"Marina" <someone@nospam.com> wrote in message
news:uAK5SiuEGHA.3200@tk2msftngp13.phx.gbl...
> 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 Mitchell" <Magella***@hotmail.com> wrote in message
> news:ueURPfuEGHA.312@TK2MSFTNGP09.phx.gbl...
>>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
>>
>>
>>
>>
>>
>>
>
>
Author
6 Jan 2006 11:03 PM
Cor Ligthert [MVP]
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

AddThis Social Bookmark Button