Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to delete listview row and update database table at the same time..

Posted on 2010-11-10
4
Medium Priority
?
562 Views
Last Modified: 2012-05-10
Hi,

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
                    UpdateFieldSequence(iCtlid, iSeq)
                Next

But this fires before the actual delete, so the column seqNr is a mess...

I hope you understand my problem.
0
Comment
Question by:mattegol
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:CmdoProg2
ID: 34104448
Is your code in the ItemDeleted event handler?
0
 

Author Comment

by:mattegol
ID: 34109699
Yes

Protected Sub ListViewFormControls_ItemDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewDeleteEventArgs) Handles ListViewFormControls.ItemDeleting

I have no problem getting it to work one by one, but I can't make it happen at the same time  by clicking the delete button.
0
 
LVL 12

Accepted Solution

by:
CmdoProg2 earned 2000 total points
ID: 34120011
I'm confused. You answered that the code is in the deleted event, but are showing the deleting event.  The deleting event occurs before the record is removed, thus renumbering will not work.  The deleted event occurs after the record has been removed.

Try ...

Protected Sub ListViewFormControls_RowDeleted(ByVal sender as Object, ByVal e As System.Web.UI.WebControls.ListViewDeletedEventArgs) Handles ListViewFormControls.ItemDeleted
0
 

Author Closing Comment

by:mattegol
ID: 34121202
Sorry my bad, I mixed it up...

It works like a charm now.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question