protected void rpItems_ItemCommand(object source, RepeaterCommandEventArgs e) { FooterDAL dal = new FooterDAL(); if (e.CommandName == "Add") { DropDownList ddlIntro = e.Item.FindControl("ddlIntro") as DropDownList; Footer footer = new Footer(); footer.Intro = ddlIntro.SelectedValue; footer.SourceType = SourceType; footer.SourceNo = SourceNo; dal.AddFooter(footer); dal.Save(); } if (e.CommandName == "Save") { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; TextBox txtIntro = e.Item.FindControl("txtIntro") as TextBox; var item = dal.GetFooterById(int.Parse(hdId.Value)); item.Intro = txtIntro.Text; dal.Save(); } if (e.CommandName == "Delete") { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; dal.DeleteFooterItem(int.Parse(hdId.Value)); } BindControl(); SetFocus(rpItems); }
public static void AddDefault(string sourceNo, string sourceType, string formType) { FooterDAL dal = new FooterDAL(); var defaultItems = Utility.GetLookupList(formType).Where(f => f.IsDefault == true); foreach (var item in defaultItems) { Footer footer = new Footer() { Intro = item.ConfigItem_Value, SourceNo = sourceNo, SourceType = sourceType }; dal.AddFooter(footer); } dal.Save(); }