DAL层
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> /// <returns></returns> public static int Delect(int id) { var sql = "select * from ClassInfo where id=@id"; SqlParameter[] sqlParameters = new SqlParameter[] { new SqlParameter("@id",id) }; return SqlHelper.NonQuery(sql, sqlParameters); }
BLL层
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> /// <returns></returns> public static int Delect(int id) { return ClassInfoDAL.Delect(id); }
UI层
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e) { var data = e.Keys["Id"]; var id = Convert.ToInt32(data); if (ClassInfoBLL.Delect(id) > 0) { var url = Request.Url.PathAndQuery; Response.Redirect(url); } }