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
Printable View
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
Is it possible at all ?
anyone ?
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.
I can do that. What about when the datagridview rows are reordered. How do I capture the new order to the database ?
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