how to call delete confirmation for gridview when its having paging

Posted by Manorama under JavaScript on 6/19/2013 | Points: 10 | Views : 1311 | Status : [Member] | Replies : 1
hi all...

Here my requirement is i am having grid view and delete button which is asp control...nearer to that.when we click On delete button it has to ask are you sure want to delete the item?In grid i am having check boxes for each row...1st it will ask Please select row which one you want to delete?

When grid view don't have paging it is working fine.If grid having paging ....then asp:button for delete is just refreshing the page.Its not showing popup window for delete confirmation.Its not calling Javascript....

Please suggest On this ...

thanks in advance



Posted by: lakhansin-22735 on: 7/4/2013 [Member] Starter | Points: 25


Can you share your Delete() javascript function?

Also, if possible then you can try same delete functionality from server side may be this will help.
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)

if (e.Row.RowType == DataControlRowType.DataRow)
// loop all data rows
foreach (DataControlFieldCell cell in e.Row.Cells)
// check all cells in one row
foreach (Control control in cell.Controls)
// Must use LinkButton here instead of ImageButton
// if you are having Links (not images) as the command button.
ImageButton button = control as ImageButton;
if (button != null && button.CommandName == "Delete")
// Add delete confirmation
button.OnClientClick = "if (!confirm('Are you sure " +
"you want to delete this record?')) return;";

Lakhan Singh
Tech Lead
BeyondKey System Pvt. Ltd.
Indore, M.P.

Manorama, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response