Sorting

  • Thread starter Thread starter Jeff Johnson
  • Start date Start date
J

Jeff Johnson

Hi,

I'm building the backend of a site for a client and one of the requirements
is to add data to populate dropdowns which is straight forward, but they
also want to control the order they appear in the dropdowns. I've created a
field called 'Sort' using an INT for the datatype. I want to determine the
how to swap the 'Sort' field values when the user chooses to to update the
order. Can someone please recommend the best way to allow a user to update
the sort field?

Name Value Sort
abc ABC 10 (change to 30)
def DEF 20
ghi GHI 30 (change to 10)

Thanks,

Jeff
 
Jeff said:
Hi,

I'm building the backend of a site for a client and one of the requirements
is to add data to populate dropdowns which is straight forward, but they
also want to control the order they appear in the dropdowns. I've created a
field called 'Sort' using an INT for the datatype. I want to determine the
how to swap the 'Sort' field values when the user chooses to to update the
order. Can someone please recommend the best way to allow a user to update
the sort field?

Name Value Sort
abc ABC 10 (change to 30)
def DEF 20
ghi GHI 30 (change to 10)

Thanks,

Jeff

List[0].SortOrder = 30;
List[2].SortOrder = 10;
 
Jeff said:
Hi,

I'm building the backend of a site for a client and one of the requirements
is to add data to populate dropdowns which is straight forward, but they
also want to control the order they appear in the dropdowns. I've created a
field called 'Sort' using an INT for the datatype. I want to determine the
how to swap the 'Sort' field values when the user chooses to to update the
order. Can someone please recommend the best way to allow a user to update
the sort field?

Name Value Sort
abc ABC 10 (change to 30)
def DEF 20
ghi GHI 30 (change to 10)

Thanks,

Jeff

Of course, you could just execute some SQL.

UPDATE yourtable SET Sort = 10 WHERE Name = 'abc'
UPDATE yourtable SET Sort = 30 WHERE Name = 'ghi'
 
Jeff said:
Hi,

I'm building the backend of a site for a client and one of the requirements
is to add data to populate dropdowns which is straight forward, but they
also want to control the order they appear in the dropdowns. I've created a
field called 'Sort' using an INT for the datatype. I want to determine the
how to swap the 'Sort' field values when the user chooses to to update the
order. Can someone please recommend the best way to allow a user to update
the sort field?

Name Value Sort
abc ABC 10 (change to 30)
def DEF 20
ghi GHI 30 (change to 10)

Thanks,

Jeff

Or you could present the user with a grid listing all the values and
just allowing him/her to edit in-place.

Why am I posting all kinds of "solutions"?

Because your problem is too vague.
 
Thanks Lasse. I'll investigate your first suggestion. I'm trying to
implement this with as little SQL as possible.

Jeff
 
Thanks Lasse.  I'll investigate your first suggestion.  I'm trying to
implement this with as little SQL as possible.

Jeff

I would give the user the options he wants then write the code for
each one.

I would have thought alphabetical order would have been best ?
 
Back
Top