Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

problem with deleting a row from datagrid after confirmation

Posted on 2004-10-19
7
Medium Priority
?
604 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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