In .aspx page
In .aspx.cs page
protected void gv_getdata_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int i = Convert.ToInt16(gv_getdata.Rows[e.RowIndex].Cells[1].Text);
string strQuery = “delete from tbl_account where id = @Id”;
SqlCommand cmd = new SqlCommand(strQuery, conn);
cmd.Parameters.Add(“@id”, SqlDbType.VarChar).Value = i;
conn.Close();
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Response.Redirect(“viewaccount.aspx”);
}
Javascript:
function confirmDelete(evt)
{
return window.confirm(“Are you sure you want to delete this record?”);
}
In .aspx.cs page
protected void gv_getdata_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int i = Convert.ToInt16(gv_getdata.Rows[e.RowIndex].Cells[1].Text);
string strQuery = “delete from tbl_account where id = @Id”;
SqlCommand cmd = new SqlCommand(strQuery, conn);
cmd.Parameters.Add(“@id”, SqlDbType.VarChar).Value = i;
conn.Close();
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Response.Redirect(“viewaccount.aspx”);
}
Javascript:
function confirmDelete(evt)
{
return window.confirm(“Are you sure you want to delete this record?”);
}