protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FST.Common.Business_Interface bi = new FST.Common.Business_Interface(); // load the races (or ethnicities) into the page DataTable dt = bi.GetRaces(); this.ddlRace.DataSource = dt; DataRow row = dt.NewRow(); row["FieldName"] = DBNull.Value; row["FieldValue"] = DBNull.Value; dt.Rows.Add(row); this.ddlRace.DataTextField = "FieldName"; this.ddlRace.DataValueField = "FieldValue"; this.ddlRace.DataBind(); this.ddlRace.Text = ""; dt.Clear(); // get the loci (for all lab kits) dt = bi.GetLocus(Guid.Empty); this.ddlLocus.DataSource = dt; row = dt.NewRow(); row["FieldName"] = DBNull.Value; row["FieldValue"] = DBNull.Value; dt.Rows.Add(row); this.ddlLocus.DataTextField = "FieldName"; this.ddlLocus.DataValueField = "FieldValue"; this.ddlLocus.DataBind(); this.ddlLocus.Text = ""; dt.Clear(); // get the alleles for the selected locus dt = bi.GetAlleles(this.ddlLocus.SelectedValue); this.ddlAlleleNo.DataSource = dt; row = dt.NewRow(); row["FieldName"] = DBNull.Value; row["FieldValue"] = DBNull.Value; dt.Rows.Add(row); this.ddlAlleleNo.DataTextField = "FieldName"; this.ddlAlleleNo.DataValueField = "FieldValue"; this.ddlAlleleNo.DataBind(); this.ddlAlleleNo.Text = ""; dt.Clear(); // get the frequencies dt = bi.GetFrequencyData(); this.gvFreqView.DataSource = dt; this.gvFreqView.DataBind(); } }
/// <summary> /// Applies sort and search to the grid /// </summary> public void PopulateGrid() { FST.Common.Business_Interface bi = new FST.Common.Business_Interface(); // get all the frequencies DataTable dt = bi.GetFrequencyData(); using (DataView dv = new DataView(dt)) { // apply race filter string strRowFilter = ""; if (!String.IsNullOrEmpty(this.ddlRace.SelectedValue)) { strRowFilter = "EthnicID = '" + this.ddlRace.SelectedValue + "'"; } // apply locus filter if (!String.IsNullOrEmpty(this.ddlLocus.SelectedValue)) { if (!String.IsNullOrEmpty(strRowFilter)) { strRowFilter += " and "; } strRowFilter += "LocusID = '" + this.ddlLocus.SelectedValue + "'"; } // apply allele filter if (!String.IsNullOrEmpty(this.ddlAlleleNo.SelectedValue)) { if (!String.IsNullOrEmpty(strRowFilter)) { strRowFilter += " and "; } strRowFilter += "AlleleID = '" + this.ddlAlleleNo.SelectedValue + "'"; } // apply all filtes to data view if (!String.IsNullOrEmpty(strRowFilter)) { dv.RowFilter = strRowFilter; } // set data view source for gridview and databind this.gvFreqView.DataSource = dv; this.gvFreqView.DataBind(); } }