protected void ctlCountryGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "SelectCountry") { // Retrieve Object Row from GridView Selected Row GridViewRow selectedRow = ((Control)e.CommandSource).NamingContainer as GridViewRow; short countryId = UIHelper.ParseShort(ctlCountryGrid.DataKeys[selectedRow.RowIndex].Value.ToString()); DbCountryLang selectedCountry = DbCountryLangService.FindByIdentity(countryId); // Return Selected Program. CallOnObjectLookUpReturn(selectedCountry); // Hide Modal Popup. this.ModalPopupExtender1.Hide(); } }
protected void ctlAdd_Click(object sender, ImageClickEventArgs e) { DbCountry ct = new DbCountry(); if (Mode.Equals(FlagEnum.EditFlag)) { ct.CountryID = CID; } ct.CountryCode = ctlCountryCode.Text; ct.Comment = ctlComment.Text; ct.Active = ctlActiveChk.Checked; ct.UpdBy = UserAccount.UserID; ct.UpdDate = DateTime.Now; ct.UpdPgm = UserAccount.CurrentLanguageCode; ct.CreDate = DateTime.Now; ct.CreBy = UserAccount.UserID; try { // save or update PB if (Mode.Equals(FlagEnum.EditFlag)) { DbCountryService.UpdateCountry(ct); } else { short cId = DbCountryService.AddCountry(ct); ct.CountryID = cId; } IList <DbCountryLang> list = new List <DbCountryLang>(); foreach (GridViewRow row in ctlCountryLangGrid.Rows) { short languageId = UIHelper.ParseShort(ctlCountryLangGrid.DataKeys[row.RowIndex]["LanguageID"].ToString()); TextBox CountryName = row.FindControl("ctlCountryName") as TextBox; TextBox Comment = (TextBox)row.FindControl("ctlComment") as TextBox; CheckBox Active = (CheckBox)row.FindControl("ctlActive") as CheckBox; DbCountryLang ctLang = new DbCountryLang(); ctLang.Active = Active.Checked; ctLang.CreBy = UserAccount.UserID; ctLang.CreDate = DateTime.Now; ctLang.Comment = Comment.Text; ctLang.Language = new DbLanguage(languageId); ctLang.Country = ct; ctLang.UpdBy = UserAccount.UserID; ctLang.UpdDate = DateTime.Now; ctLang.UpdPgm = UserAccount.CurrentLanguageCode; ctLang.CountryName = CountryName.Text; list.Add(ctLang); } if (Mode.Equals(FlagEnum.EditFlag)) { DbCountryLangService.UpdateCountryLang(list); } if (Mode.Equals(FlagEnum.NewFlag)) { DbCountryLangService.UpdateCountryLang(list); } Notify_Ok(sender, e); } catch (ServiceValidationException ex) { this.ValidationErrors.MergeErrors(ex.ValidationErrors); UpdatePanelCountryForm.Update(); } }