Results 1 to 6 of 6

Thread: [2008] Datagridview : databound - reorder rows

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    [2008] Datagridview : databound - reorder rows

    I have a databound datagridview.

    I need to drag drop and reorder entire rows and have the changes reflected in the database.

    Can someone please help with a solution to this ?

    Thanks

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    Re: [2008] Datagridview : databound - reorder rows

    Is it possible at all ?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    Re: [2008] Datagridview : databound - reorder rows

    anyone ?

  4. #4
    Addicted Member
    Join Date
    Dec 2008
    Posts
    185

    Re: [2008] Datagridview : databound - reorder rows

    give the rows an order number which you can update (you don't need to display it).

    Then when you retrieve rows from your database, add an 'order by rownumber' clause to the sql statement.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    Re: [2008] Datagridview : databound - reorder rows

    I can do that. What about when the datagridview rows are reordered. How do I capture the new order to the database ?

  6. #6
    Addicted Member
    Join Date
    Dec 2008
    Posts
    185

    Re: [2008] Datagridview : databound - reorder rows

    I'm not sure how your doing your db updates or databinding, but running through something like this just before you update (after row reordering) should do it:

    Code:
            For Each row As DataGridViewRow In DataGridView1.Rows
                CType(row.DataBoundItem, DataRow).Item("RowNumber") = row.Index
            Next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width