Ordering items in ListBox

Discussion in 'ASP .Net' started by =?Utf-8?B?RGlnZ2xlcg==?=, May 4, 2004.

  1. I have a group of items in the database that need to be sorted by the client. There is a field in the database that stores the desired order (0, 1, 2, etc...). I would like to allow the client to move the ListBox.Items up and down in the ListBox via JavaScript and then, on the form submit, read the items in the ListBox from the client IN ORDER so I can save the changes in position into the database.

    Unfortunately, the server is unaware of the changes in the ListBox. While in the 'for' loop, it remembers from server memory the original order rather than actually read them from the client.

    Is there any way to read the actual order of the items from the client?
     
    =?Utf-8?B?RGlnZ2xlcg==?=, May 4, 2004
    #1
    1. Advertising

  2. The biggest task is reconstructing the list box from scratch each time the
    user moves an item up or down using client side JavaScript. This is no small
    order, but it is very possible to do.

    Specifically, there is no index to adjust with the HTML select input list
    box. You must dump the contents into an array, clear the list box and then
    repopulate the list box with list items. Each listbox item has a value and
    a display text property. Set the value property to the desired list order
    index which will then be used by your server side executing code.

    Remember it's HTML, it's light weight and following w3c specifications.
    Unlike say a rich client windows forms application, much of the creative
    coding is left up to you -in this case an HTML select input. Good luck.
    --
    Peter O'Reilly
     
    Peter O'Reilly, May 4, 2004
    #2
    1. Advertising

  3. Hi

    ListBox is only supposed submit selection to server not the order. You might need to add a hidden field(runat server) and store the client changed order like "3,2,4,1". Then you can handle it on server

    Bin Song, MCP
     
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 4, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kent
    Replies:
    1
    Views:
    881
    Andrew de la Harpe
    May 3, 2004
  2. Stimp

    re-ordering ListBox items

    Stimp, Nov 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,100
    Stimp
    Nov 19, 2004
  3. K B
    Replies:
    2
    Views:
    670
  4. Tomas
    Replies:
    1
    Views:
    574
    Munna
    Aug 12, 2008
  5. nbigaouette

    Z-Ordering (Morton ordering) question

    nbigaouette, Nov 5, 2009, in forum: C Programming
    Replies:
    2
    Views:
    2,168
Loading...

Share This Page