protected void btn_Save_Click(object sender, EventArgs e) { int id = WS.RequestInt("id"); DataEntities ent = new DataEntities(); TemplateList tl ; try { tl = (from l in ent.TemplateList where l.ID == id select l).First(); } catch { tl = new TemplateList(); } tl.TempName = txt_TempName.Text; tl.CutKeywords = txt_CutKeywords.Text.ToInt32(); tl.CutTitle = txt_CutTitle.Text.ToInt32(); tl.ShowRecordCount = txt_ShowRecordCount.Text.ToInt32(); tl.TimeFormat = txt_TimeFormat.Text; tl.Content = txt_Content.Text.Replace("'", "''"); ; tl.ListVar = txt_Listvar.Text.Replace("'", "''"); ; tl.SysModel = ddl_SysModel.SelectedValue.ToInt32(); if (tl.ID <= 0) { tl.GroupID = 1; tl.SysModel = 1; ent.AddToTemplateList(tl); } ent.SaveChanges(); ent.Dispose(); Js.AlertAndGoback("保存成功!"); }