How to delete listview row and update database table at the same time..
Posted on 2010-11-10
I have a listview that has this selectcommand:
SelectCommand="SELECT * FROM [XXX] WHERE ([id] = @id) ORDER BY [seqNr] ASC"
I have no problem deleteing a row in my listview:
DeleteCommand="DELETE [XXX] WHERE ([ControlId]=@ControlId)"
I want the seqNr to be updated at the same time as the row is deleted. For example I have a lisview with 10 rows and I delete row 7, then I want to the column seqNr in my table to be updated. I have tried something like this:
Dim iSeq As Integer
Dim iCtlid As Integer
Dim i As Integer
Dim test As String
test = ListViewFormControls.Items.Count
For i = 0 To ListViewFormControls.Items.Count - 1
iCtlid = ListViewFormControls.DataKeys(i).Value
iSeq = i + 1
But this fires before the actual delete, so the column seqNr is a mess...
I hope you understand my problem.