I have class called Item which has Id ,Name column and Creating Item table in DB.
Suppose i have retrieve a table like this in DataGrid .
Id Name
1 pen
2 pencil
3 eraser
4 book
5 sharpener
If i delete Id having 3.Then after deleting Id should be in ascending Order.Like this and it should reflect in Datagrid after Deleting
Id Name
1 pen
2 pencil
3 book
4 sharpener
Kindly help!!


Iftikar HussainRank #423 · 5.9K reputationPosted Sep 18, 2013, 11:02 PM EDT
Is the ID column is identity column?
Regards,
Iftikar
Kiran Kumar TalikotiRank #814 · 2.8K reputationPosted Sep 18, 2013, 11:50 PM EDT
Id is the Primary Key.If i delete 1 Id and remaining Ids should arrange in ascending order?
As i show in 2nd table
Jignesh TrivediRank #16 · 50.3K reputationPosted Sep 19, 2013, 2:55 AM EDT
hi,
I think this may be achive by stored procedure
CREATE PROCEDURE DeleteRecord
(
@Id INT
)
BEGIN
DELETE ItemMaster where id = @Id
UPDATE ItemMaster
SET id = id -1
where id > @Id
END
hope this will help you.