Hi all,
In my grid view row command i want to delete the row with confirmation alert box(javascript alert ), upto alert box is working fine , but the problem is , The Row command is fired immediately that is not waiting for alert box
grid control
------------
<asp:TemplateField ItemStyle-Width="25px" ItemStyle-Height="15px">
<ItemTemplate>
<asp:ImageButton ID="lnkswi_del" runat="server" CommandName="Delete" ToolTip="Delete"
CommandArgument="<%#CType(Container,GridViewRow).RowIndex%>" ImageUrl="~/Images/delete.png" CssClass="test" OnClientClick="return Confirmdelete();" />
</ItemTemplate>
</asp:TemplateField>
javascript
-----------
function ConfirmDelete() {
alertify.set({ buttonReverse: true });
alertify.confirm('Are you sure you want to delete the record?', function (e) {
if (e) {
return true;
} else {
return false;
}
});
}
code behind
-----------
Protected Sub gridTran_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gridTran.RowCommand
If e.CommandName = "Delete" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim gvRow As GridViewRow = gridTran.Rows(index)
trxnno = gvRow.Cells(1).Text
deletemethod() // this method will delete the row
End If
after click the alert box ok only the row command event should fire , but its not
help me resolve this
and also , i did it through rowdatabound event, ther also the same problem is occuring
Protected Sub gridTran_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gridTran.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
Dim theDeleteButton As ImageButton = CType(e.Row.Cells(0).FindControl("lnkswi_del"), ImageButton)
theDeleteButton.OnClientClick = "return ConfirmDelete();"
End If
End Sub
thanks in advance
Velsamy