protected void BindLanguages(string Language) { try { //Get List From DB List <contentlanguage> Languages = App_Code.ContentService.GetContentLanguageList(); //Create an option to Add Language contentlanguage NewLanguage = new contentlanguage(); NewLanguage.language = "Add Language"; Languages.Add(NewLanguage); //Databind ddlContentLanguage.DataSource = Languages; ddlContentLanguage.DataTextField = "language"; ddlContentLanguage.DataValueField = "language"; ddlContentLanguage.DataBind(); //Set Default ddlContentLanguage.SelectedValue = Language; } catch (Exception ex) { //Error App_Code.NotificationService.SendNotification("BindLanguageError", ex.Message, "error"); } }
protected void btnNewLanguage_Click(object sender, EventArgs e) { try { contentlanguage NewLanguage = new contentlanguage(); NewLanguage.language = txtNewLanguage.Text.Trim().Replace(" ", ""); App_Code.ContentService.SaveObject(NewLanguage); BindLanguages(NewLanguage.language); App_Code.NotificationService.SendNotification("NewLanguageSuccess", "Language Added Successfully", "success", "4000"); txtNewLanguage.Text = ""; } catch (Exception ex) { //Error App_Code.NotificationService.SendNotification("NewLanguage", ex.Message, "error"); } }