I have couple of rows in database table (lets call it Customer), each row is numbered by SNo which gets automatically incremented by the identity property inherent in MS SQLServer. But when i delete a particular row that particular row number is left blank but I want the table to auto correct itself.
To give you a example:
I have a sample Customer Table with following rows:
SNo CustomerName Age
1 Dani 28
2 Alex 29
3 Duran 21
4 Mark 24
And suppose I delete 3rd row the table looks like this:
SNo CustomerName Age
1 Dani 28
2 Alex 29
4 Mark 24
But I want the table to look like this:
SNo CustomerName Age
1 Dani 28
2 Alex 29
3 Mark 24
How can i achieve that using LINQ to SQL in c#? This is for presentation in gridview only, i don't want the SNo to be changed in database table, just want to show the right order to users.
I'm using the following lines of code:
(db.Components.AsEnumerable().Select((iterator)=> new{iterator.SNo + 1})
But i'm not getting any result, how can i achieve it, i just want the sno to be incremented regardless of the value in database table
Please help me out
Thanks in anticipation
PS: please dont flag it or downvote for some reason u might delete after getting answered