protected void btn_Click(object sender, EventArgs e) { LinksDal db = new LinksDal(); Links item = new Links(); item.Title = txt1.Text; item.LinkStr = txt2.Text; db.Add(item); load(); }
//提交保存 protected void btnsave_Click(object sender, EventArgs e) { if (Request["type"] == "Edit") { long Id = Convert.ToInt64(Request["ID"]); var item = db.Find(Id); if (item != null) { item.Title = txtbt.Text; item.LinkStr = txtdz.Text; if (db.Edit(item)) { Page.ClientScript.RegisterStartupScript(GetType(), "e1", "edOK();", true); } else { Page.ClientScript.RegisterStartupScript(GetType(), "e2", "layer.alert('修改失败');", true); } } else { //找不到数据就返回列表 Response.Redirect("LinksListPG.aspx"); } } else { Models.Links item = new Models.Links(); item.Title = txtbt.Text; item.LinkStr = txtdz.Text; if (db.Add(item)) { Page.ClientScript.RegisterStartupScript(GetType(), "a1", "adOK()", true); } else { Page.ClientScript.RegisterStartupScript(GetType(), "a2", "layer.alert('添加失败');", true); } } }