private void LoadSponsor() { List <ATTSponsor> SponsorLST = BLLSponsor.GetSponsorList(0, "Y"); Session["Sponsors"] = SponsorLST; this.ddlSponsors.DataSource = SponsorLST; this.ddlSponsors.DataValueField = "SponsorID"; this.ddlSponsors.DataTextField = "SponsorName"; this.ddlSponsors.DataBind(); }
private void LoadSponsors() { try { List <ATTSponsor> SponsorLST = BLLSponsor.GetSponsorList(0, "N"); Session["Sponsors"] = SponsorLST; lstSponsors.DataSource = SponsorLST; lstSponsors.DataTextField = "SponsorName"; lstSponsors.DataValueField = "SponsorID"; lstSponsors.DataBind(); } catch (Exception ex) { throw ex; } }
protected void btnSubmit_Click(object sender, EventArgs e) { List <ATTSponsor> SponsorLST = (List <ATTSponsor>)Session["Sponsors"]; ATTSponsor obj = new ATTSponsor(); if (lstSponsors.SelectedIndex == -1) { obj = SponsorLST.Find ( delegate(ATTSponsor objSp) { return(objSp.SponsorName.ToLower() == this.txtSponsorName_RQD.Text.ToLower()); } ); if (obj != null) { this.lblStatusMessage.Text = "Sponsor Name Already Exists"; this.programmaticModalPopup.Show(); return; } } //else //{ // obj = SponsorLST.Find // ( // delegate(ATTSponsor objSp) // { // return objSp.SponsorName.ToLower() == this.txtSponsorName_RQD.Text.ToLower() && objSp.SponsorID!=int.Parse(lstSponsors.SelectedValue); // } // ); //} ATTSponsor objSponsor = new ATTSponsor( (lstSponsors.SelectedIndex == -1) ? 0 : int.Parse(lstSponsors.SelectedValue), this.txtSponsorName_RQD.Text.Trim(), (lstSponsors.SelectedIndex == -1) ? "A" : "E"); ObjectValidation OV = BLLSponsor.Validate(objSponsor); if (OV.IsValid == false) { this.lblStatusMessage.Text = OV.ErrorMessage; this.programmaticModalPopup.Show(); return; } if (BLLSponsor.AddProgram(objSponsor) == true) { if (lstSponsors.SelectedIndex == -1) { SponsorLST.Add(objSponsor); } else { SponsorLST[lstSponsors.SelectedIndex].SponsorName = this.txtSponsorName_RQD.Text.Trim(); } } lstSponsors.DataSource = SponsorLST; lstSponsors.DataTextField = "SponsorName"; lstSponsors.DataValueField = "SponsorID"; lstSponsors.DataBind(); clearAll(); }