Shuffling rows in a GridView

Discussion in 'ASP .Net Web Controls' started by justin, Sep 1, 2006.

  1. justin

    justin Guest

    One of the gridviews i'm using now apparently needs to have the added
    functionality of re-arranging the order of the records it's
    representing. These records have a priority field which the dataset
    gets sorted on and I thought the quickest way to do this would be to
    add "move up", "move down" buttons next to the grid which would shuffle
    the rows up and down by swapping their priority field values and
    updating.

    At least that seemed to be the quickest way before I spent a day
    pouring through documentation trying to find a way to get at the
    dataset of the gridview with no success whatsoever. Thing's locked up
    tighter than a duck's. Is there any way on God's green earth to access
    the data of a gridview? Or is there a better way to do this, you see it
    all the time with listboxes I'd hoped I could get the gridview to play
    along...
    justin, Sep 1, 2006
    #1
    1. Advertising

  2. justin

    justin Guest

    Thanks for the reply Alvin,
    Yes a listbox would be a far more clever solution but the existing page
    uses the gridview's edit functionality so I can't really change it to a
    listbox. And you're right, you just have to re-order the dataset. I
    just can't find any way to prise that dataset out of the gridview, or
    the objectdatasource that i'm using for it. There doesn't seem to be
    any way to get to it.

    Alvin Bruney [MVP] wrote:
    > I don't believe this is built in simply because row order is not usually an
    > overriding concern. But's it's really easy to do. Just re-order the
    > datasource, dataview, or dataset and rebind.
    >
    > On second thought, if you need flexibility in row ordering, you should be
    > using a listbox and not a gridview.
    >
    > --
    > ________________________
    > Warm regards,
    > Alvin Bruney [MVP ASP.NET]
    >
    > [Shameless Author plug]
    > Professional VSTO.NET - Wrox/Wiley
    > The O.W.C. Black Book with .NET
    > www.lulu.com/owc, Amazon
    > Blog: http://www.msmvps.com/blogs/alvin
    > -------------------------------------------------------
    >
    >
    > "justin" <> wrote in message
    > news:...
    > > One of the gridviews i'm using now apparently needs to have the added
    > > functionality of re-arranging the order of the records it's
    > > representing. These records have a priority field which the dataset
    > > gets sorted on and I thought the quickest way to do this would be to
    > > add "move up", "move down" buttons next to the grid which would shuffle
    > > the rows up and down by swapping their priority field values and
    > > updating.
    > >
    > > At least that seemed to be the quickest way before I spent a day
    > > pouring through documentation trying to find a way to get at the
    > > dataset of the gridview with no success whatsoever. Thing's locked up
    > > tighter than a duck's. Is there any way on God's green earth to access
    > > the data of a gridview? Or is there a better way to do this, you see it
    > > all the time with listboxes I'd hoped I could get the gridview to play
    > > along...
    > >
    justin, Sep 5, 2006
    #2
    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. glowfire

    random shuffling

    glowfire, Feb 19, 2005, in forum: C++
    Replies:
    16
    Views:
    789
    Martijn Mulder
    Feb 23, 2005
  2. SilverWolf

    sorting and shuffling array

    SilverWolf, Oct 13, 2003, in forum: C Programming
    Replies:
    3
    Views:
    358
    Richard Heathfield
    Oct 14, 2003
  3. greenflame

    shuffling elements of a list

    greenflame, May 31, 2006, in forum: Python
    Replies:
    22
    Views:
    630
    Peter Otten
    Jun 2, 2006
  4. justin

    Shuffling rows in a GridView

    justin, Sep 1, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    8,975
    Alvin Bruney [MVP]
    Sep 15, 2006
  5. Replies:
    8
    Views:
    341
    Howard
    Mar 20, 2006
Loading...

Share This Page