|
private void DataGrid1_DeleteCommand (object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
Ranch
try
{
string Con = ConfigurationSettings.AppSettings ["Conn"];
con = new SqlConnection (Con);
c = new Blog.classes.Classtx ();
Ranch
cmd = new SqlCommand ("delete Blog_UAddrClass where sid = @ sid", con);
cmd.Parameters.Add (new SqlParameter ("@ sid", SqlDbType.Int));
cmd.Parameters ["@ sid"]. Value = this.DataGrid1.DataKeys [(int) e.Item.ItemIndex];
Ranch
Response.Write ("<script language = javascript> confirm ('Are you sure you want to delete?') </ Script>"); // When I want to operate it, I will let it delete, otherwise I will do nothing
if (c.rowcout (Convert.ToInt32 (DataGrid1.DataKeys [(int) e.Item.ItemIndex])))> 0&&c.classnamecout (Session ["Username"]. ToString ())> 1)
{
Response.Redirect ("deletedata.aspx? Sid =" + DataGrid1.DataKeys [(int) e.Item.ItemIndex] .ToString () + "&rowcount =" + c.rowcout (Convert.ToInt32 (DataGrid1.DataKeys [(int ) e.Item.ItemIndex])));
Ranch
}
else
{
Ranch
c.delete (Convert.ToInt32 (DataGrid1.DataKeys [(int) e.Item.ItemIndex]));
Ranch
}
cmd.Dispose ();
con.Close ();
c.bindGraid (this.DataGrid1, Session ["Username"]. ToString ());
}
Ranch
catch (Exception ex)
{
Ranch
} |
|