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

x
?
Solved

problem with deleting a row from datagrid after confirmation

Posted on 2004-10-19
7
Medium Priority
?
606 Views
Last Modified: 2008-03-03

hi all ,

i wanted to delete a row from the datagrid after confiramtion .i have used the same way that is given in the below link .
http://builder.com.com/5100-6373-1049811.html#Listing%20E
but the form is being posted even after i click on cancel . can any one pls tell me why this is happening. i have written the delete code both in the ItemCommand and also in deleteCommand function and tried . but the form is begin posted back even after i click on cancel of confirm dialog box .

regards
ITkid.

0
Comment
Question by:ITkid
  • 2
7 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 12355606
Hi ITkid,


are you sure you have added this line exectly as it said:
l.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item?');")

Regards!
B..M
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 12355608
Show how you are calling the confirmation.

If it is javascript confirmation you have to use the return statement. For example

<a href="link.aspx" onClick="return confirm('Are you sure you want to remove this item?')">delete</a>

This way the link.aspx will only be executed after you click OK in the dialog. So, what does your code look like?
0
 
LVL 2

Accepted Solution

by:
dwcorwith earned 500 total points
ID: 12357827
I just used the exact same code in my app.  I found an omission in the builder.com code you referenced.  Add the CommandName attribute to the linkbutton.
<asp:linkbutton id="cmdDel" runat="Server" CommandName="SelectDelete" </asp:linkbutton>

Now in your sub:
Sub DataGrid1_ItemCommand(ByVal s As Object, ByVal e As DataGridCommandEventArgs)
    Select Case e.CommandName
        Case "SelectDelete"
             'Delete the record code goes here (his Listing E)
    End Select
End Sub

It works great for me.  If the user clicks on "OK" of the confirm box it will call this sub.  If the user clicks on cancel, nothing should happen.  (This sub will NOT be called)
Hope this clarifys it.  
dwcorwith
0
 
LVL 2

Expert Comment

by:dwcorwith
ID: 12380737
Oops I forgot, you will also need the following in the <asp:Datagrid > statement
<asp:DataGrid1  OnItemCommand="DataGrid1_ItemCommand"/>
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Screencast - Getting to Know the Pipeline
Suggested Courses

885 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