gridview buttonfield click
-
Hi all, I have a gridview in which i used button field to delete record from database on "onrowcommand" event of gridview. It works properly. But I want confirmation of delete before deleting record from database on client click. so i think for that i need to call javascript confirm box on click and if it returns true then only onrowcommand event of control to be executed. Is it possible that way.if yes then suggest the code otherwise suggest another way. DataKeyNames="ID" DataSourceID="SqlDataSource1" PageSize="15" AllowSorting="True" OnRowCommand = "GridView1_RowCommand" CellPadding="4" ForeColor="#333333" GridLines="None" style="width: 100%"> Text="Delete" ImageUrl="~/images/deleteicon.jpg"> protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "delete_property_details") { int index = Convert.ToInt16(e.CommandArgument); other code placed here } }
-
Hi all, I have a gridview in which i used button field to delete record from database on "onrowcommand" event of gridview. It works properly. But I want confirmation of delete before deleting record from database on client click. so i think for that i need to call javascript confirm box on click and if it returns true then only onrowcommand event of control to be executed. Is it possible that way.if yes then suggest the code otherwise suggest another way. DataKeyNames="ID" DataSourceID="SqlDataSource1" PageSize="15" AllowSorting="True" OnRowCommand = "GridView1_RowCommand" CellPadding="4" ForeColor="#333333" GridLines="None" style="width: 100%"> Text="Delete" ImageUrl="~/images/deleteicon.jpg"> protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "delete_property_details") { int index = Convert.ToInt16(e.CommandArgument); other code placed here } }
In the ItemDataBound event you can add a confirm dialog to a button like so:
deleteButton.Attributes.Add("onClick", "return confirm('Confirm that you want to delete this record!');");
Declan Bright www.declanbright.com