this question has answer here:
i need popup confirmation on button click deleting rows asp.net gridview using c#. below code button click deleting rows gridview. require popup confirmation before deleting.
here code
protected void anndelete_click(object sender, eventargs e) { foreach (gridviewrow row in gridview1.rows) { checkbox cb = (checkbox)row.findcontrol("chk_delete"); if (cb.checked && cb != null) { { int id_no = convert.toint32(gridview1.datakeys[row.rowindex].value); mysqlcommand com = new mysqlcommand(); com.commandtext = "delete announcement id = '" + id_no + "'"; com.connection = con; //con.open(); com.executenonquery(); con.close(); gridview1.datasource = null; } } } loadissuedata(); }
assuming anndelete asp.net button control may put following code ask client confirmation:
html:
<asp:button id="anndelete" onclientclick="if(!confirm('confirm delete?')) return false;"></asp:button>
return false
avoid server side hit.
Comments
Post a Comment