Hi,
I'm trying to prompt for confirmation when the user deletes from a gridview. My codes are not prompting. It'll just delete without prompting. The Edit and Delete link button is at the first column.
Please advise. TIA !
aspx
====
<asp:GridView ID="GridView2" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="app_id" DataSourceID="SqlDataSource1" EnableModelValidation="True" Height="345px" Width="762px" BorderColor="Black" BorderStyle="Solid"
CssClass="auto-style7">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="app_id" HeaderText="App ID" InsertVisible="False" ReadOnly="True" SortExpression="app_id" />
<asp:BoundField DataField="app_name" HeaderText="App Name" SortExpression="app_name" />
<asp:BoundField DataField="remarks" HeaderText="Remarks" SortExpression="remarks" />
<asp:BoundField DataField="app_owner_email" HeaderText="App Owner Email" SortExpression="app_owner_email" />
<asp:BoundField DataField="group_email" HeaderText="Group Email" SortExpression="group_email" />
</Columns>
</asp:GridView>
Behind codes
============
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// reference the Delete LinkButton
LinkButton db = (LinkButton)e.Row.Cells[1].Controls[2];
// Get information about the product bound to the row
//Nothwind.ProductsRow product = (e.ProductsRow) ((System.Data.DataRowView) e.Row.DataItem).Row;
db.OnClientClick = string.Format("return confirm('Are you sure you want to delete?');");
}
}