标签:
后台C#代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Delete : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["uid"] != null) { if (!IsPostBack) { testDataContext context = new testDataContext(); //取主键值 string code = Request["code"].ToString(); //查出数据 Info data = context.Info.Where(p => p.Code == code).First(); //删除 //先删除外键表 var queryw = context.Work.Where(p => p.InfoCode == code); context.Work.DeleteAllOnSubmit(queryw); var queryf = context.Family.Where(p => p.InfoCode == code); context.Family.DeleteAllOnSubmit(queryf); //删除自身 context.Info.DeleteOnSubmit(data); //提交 context.SubmitChanges(); //返回 Response.Redirect("Main.aspx"); } } else { Response.Redirect("DengLu.aspx"); } } }
标签:
原文地址:http://www.cnblogs.com/zhuxu/p/5064801.html