protected void Drpyr_SelectedIndexChanged(object sender, EventArgs e) { try { if (Drpyr.SelectedItem.Text != "Select Year") { int yrval = Convert.ToInt32(Drpyr.SelectedItem.Text); var periodyr = (from q in db.Siddeswari_Master_Events where q.SiddOrgYearofevent == yrval select new { period = q.SiddOrgPeriodStdate + "*" + q.SiddOrgPeriodEnddate }).ToList(); Drpperiod.DataSource = null; Drpperiod.DataSource = periodyr; Drpperiod.DataTextField = "period"; Drpperiod.DataValueField = "period"; Drpperiod.DataBind(); Drpperiod.Items.Insert(0, new ListItem("Select Period", "0")); } else { populateyrper(); popultedefltval(); } } catch (Exception ex) { throw (ex); } }
protected void populateyrper() { try { var yrperiod = (from q in db.Siddeswari_Master_Events where q.SiddOrgYearofevent >= DateTime.Now.Year where q.SiddOrgPlaceofevent == "IND" select new { q.SiddOrgYearofevent }).ToList().Distinct(); Drpyr.DataSource = yrperiod; Drpyr.DataTextField = "SiddOrgYearofevent"; Drpyr.DataValueField = "SiddOrgYearofevent"; Drpyr.DataBind(); Drpyr.Items.Insert(0, new ListItem("Select Year", "0")); var perd = (from q in db.Siddeswari_Master_Events where q.SiddOrgYearofevent >= DateTime.Now.Year where q.SiddOrgPlaceofevent == "IND" select new { experd = q.SiddOrgPeriodStdate + " To " + q.SiddOrgPeriodEnddate }).ToList(); Drpperiod.DataSource = perd; Drpperiod.DataTextField = "experd"; Drpperiod.DataValueField = "experd"; Drpperiod.DataBind(); Drpperiod.Items.Insert(0, new ListItem("Select Period", "0")); } catch (Exception ex) { throw (ex); } }