J
JenHu
Hi experts,
I want to add a delete button in my datagrid, and before it deletes
from database, I want to have a confirm dialog box for this deletion.
I am entry level to the vb.net, and don't know java or c#.
The problem is, when I tested the program, there is no pop-up
confirmation box for the deletion, can you show me what' wrong with
this code? Thank you.
<asp:datagrid id="dgAppStatus" Runat="server"
AutoGenerateColumns="False" OnDeleteCommand="dgAppStatus_Delete"
DataKeyField="EmployID">
<Columns>
<asp:BoundColumn DataField="EmployID" SortExpression="EmployID"
HeaderText="Employee ID"></asp:BoundColumn>
<asp:BoundColumn DataField="LASTNAME" SortExpression="LASTNAME"
HeaderText="Last Name"></asp:BoundColumn>
<asp:BoundColumn DataField="FRSTNAME" SortExpression="FRSTNAME"
HeaderText="First Name"></asp:BoundColumn>
<asp:TemplateColumn><ItemTemplate>
<asp:Button ID="btnDelete" Text="Delete"
Runat="server"></asp:Button></ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
Sub dgAppStatus_Delete(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
btnDelete.Attributes.Add("onclick", "return confirm ('Are you
sure you wish to delete this record?')")
End Sub
I want to add a delete button in my datagrid, and before it deletes
from database, I want to have a confirm dialog box for this deletion.
I am entry level to the vb.net, and don't know java or c#.
The problem is, when I tested the program, there is no pop-up
confirmation box for the deletion, can you show me what' wrong with
this code? Thank you.
<asp:datagrid id="dgAppStatus" Runat="server"
AutoGenerateColumns="False" OnDeleteCommand="dgAppStatus_Delete"
DataKeyField="EmployID">
<Columns>
<asp:BoundColumn DataField="EmployID" SortExpression="EmployID"
HeaderText="Employee ID"></asp:BoundColumn>
<asp:BoundColumn DataField="LASTNAME" SortExpression="LASTNAME"
HeaderText="Last Name"></asp:BoundColumn>
<asp:BoundColumn DataField="FRSTNAME" SortExpression="FRSTNAME"
HeaderText="First Name"></asp:BoundColumn>
<asp:TemplateColumn><ItemTemplate>
<asp:Button ID="btnDelete" Text="Delete"
Runat="server"></asp:Button></ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
Sub dgAppStatus_Delete(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
btnDelete.Attributes.Add("onclick", "return confirm ('Are you
sure you wish to delete this record?')")
End Sub