getting data back the order as it appears in datagridview
-
hi, It would be quite an important thing for the user to get the data back in the order as it appears in the datagridview. rows of data are got from other gridviews (user clicks on other grids' rows and rows are copied to the gridview in question) so... no problem until user adds rows from the beginning(0 rows), and then saves his data, but: if user add rows the deletes rows then adds the same row again and save, the newly added row appears the first, however it was added the last. (BindingSource.Endedit is called each operation) any idea?? I also tried the BindingSource.ResetBindings() method, but that didn't helped. for saving tableadapter.update() is called. thx, g
-
hi, It would be quite an important thing for the user to get the data back in the order as it appears in the datagridview. rows of data are got from other gridviews (user clicks on other grids' rows and rows are copied to the gridview in question) so... no problem until user adds rows from the beginning(0 rows), and then saves his data, but: if user add rows the deletes rows then adds the same row again and save, the newly added row appears the first, however it was added the last. (BindingSource.Endedit is called each operation) any idea?? I also tried the BindingSource.ResetBindings() method, but that didn't helped. for saving tableadapter.update() is called. thx, g
Did you know that databases do not care about the order of records in a table?? Unless told otherwise with a ORDER BY clause, a SELECT statement can return records in any order. About the only way to accomplish this would be to give each record in the table an index number specifying which row in the view it is in. When you write the data back out to the database, you'd have to include this view order number with the data and store it in it's own column in the table. When you retrieve the data again, you'd have to specify and ORDER BY clause on that view order column in the SELECT statement, thereby guaranteeing that you get a table sorted in the order the user last saw it.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Did you know that databases do not care about the order of records in a table?? Unless told otherwise with a ORDER BY clause, a SELECT statement can return records in any order. About the only way to accomplish this would be to give each record in the table an index number specifying which row in the view it is in. When you write the data back out to the database, you'd have to include this view order number with the data and store it in it's own column in the table. When you retrieve the data again, you'd have to specify and ORDER BY clause on that view order column in the SELECT statement, thereby guaranteeing that you get a table sorted in the order the user last saw it.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007thx that gives me the idea.... now only 1 question left.for the accomplish of the above is it OK to have an [int-increment 1 ] identity (primary key)column for this?
-
thx that gives me the idea.... now only 1 question left.for the accomplish of the above is it OK to have an [int-increment 1 ] identity (primary key)column for this?
Each record is going to need it's own identity, yes, but it's useless in the row order because your users can rearrange the rows. You'd actually need BOTH colums, one for an ID key and the other for the row position in the view.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Each record is going to need it's own identity, yes, but it's useless in the row order because your users can rearrange the rows. You'd actually need BOTH colums, one for an ID key and the other for the row position in the view.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Thanks Dave problem solved