Link to home
Start Free TrialLog in
Avatar of ITkid
ITkid

asked on

problem with deleting a row from datagrid after confirmation


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.

Avatar of mmarinov
mmarinov

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
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?
ASKER CERTIFIED SOLUTION
Avatar of dwcorwith
dwcorwith

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops I forgot, you will also need the following in the <asp:Datagrid > statement
<asp:DataGrid1  OnItemCommand="DataGrid1_ItemCommand"/>