I have been racking my brain and searching the web on how to do this, but no luck.
The problem,
I have a datagrid
which allows the user to add or delete rows as they please, it is indexed via an Index column which is NOT a PK column in the Databse, eg: ID is the PK column in this case,
ID | Name | Index
Guid 1 | Name 1 | 1
Guid 2 | Name 2 | 2
Guid 3 | Name 3 | 3
Guid 4 | Name 4 | 4
Guid 5 | Name 5 | 5
So when as using deletes a row this happens: In this example Row 2,
ID | Name | Index
Guid 1 | Name 1 | 1
Guid 3 | Name 3 | 3
Guid 4 | Name 4 | 4
Guid 5 | Name 5 | 5
So how do I reset the Index keeping the current order when a row is deleted? So it looks like this,
ID | Name | Index
Guid 1 | Name 1 | 1
Guid 3 | Name 3 | 2
Guid 4 | Name 4 | 3
Guid 5 | Name 5 | 4
I have looked at Reset identity seed after deleting records in SQL Server , but this is server side and I want to do this application side via C#, not to mention this seems to only work for PK columns?
How would I go about doing something like this?