protected void DropDownDistrict_SelectedIndexChanged(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["tomms_prodConnectionString"].ConnectionString; SqlConnection con = null; try { string testing = DropDownDistrict.SelectedItem.Text; if (testing != "ALL") { con = new SqlConnection(connString); /*For Circle Dropdown Load*/ string Com2 = "select RowID , ast_loc_circle from ast_loc (nolock) where ast_loc_state = '" + DropDownState.SelectedItem.Text + "' and ast_loc_ast_loc = '" + DropDownDistrict.SelectedItem.Text + "'"; SqlDataAdapter adpt2 = new SqlDataAdapter(Com2, con); DataTable dt2 = new DataTable(); adpt2.Fill(dt2); DropDowncircle.DataSource = dt2; DropDowncircle.DataBind(); DropDowncircle.DataTextField = "ast_loc_circle"; DropDowncircle.DataValueField = "RowID"; DropDowncircle.DataBind(); } else { con = new SqlConnection(connString); /*For Circle Dropdown Load*/ string Com2 = "select RowID , ast_loc_circle from ast_loc (nolock) where ast_loc_state = '" + DropDownState.SelectedItem.Text + "' and ast_loc_ast_loc = '" + DropDownDistrict.SelectedItem.Text + "'"; SqlDataAdapter adpt2 = new SqlDataAdapter(Com2, con); DataTable dt2 = new DataTable(); adpt2.Fill(dt2); DropDowncircle.DataSource = dt2; DropDowncircle.DataBind(); DropDowncircle.DataTextField = "ast_loc_circle"; DropDowncircle.DataValueField = "RowID"; DropDowncircle.DataBind(); DropDowncircle.Items.Insert(0, new ListItem("ALL", "0")); } } catch (Exception ex) { //log error //display friendly error to user string msg = "Insert Error:"; msg += ex.Message; } }
protected void DropDownState_SelectedIndexChanged(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["tomms_prodConnectionString"].ConnectionString; SqlConnection con = null; try { con = new SqlConnection(connString); /*For Zone Dropdown Load*/ if (DropDownState.SelectedItem.Text == "ALL") { string com01 = "select distinct ast_loc_zone , ast_loc_zone from ast_loc (nolock)"; SqlDataAdapter adptzo = new SqlDataAdapter(com01, con); DataTable dtzo = new DataTable(); adptzo.Fill(dtzo); DropDownZone.DataSource = dtzo; DropDownZone.DataBind(); DropDownZone.DataTextField = "ast_loc_zone"; DropDownZone.DataValueField = "ast_loc_zone"; DropDownZone.DataBind(); DropDownZone.Items.Insert(0, new ListItem("ALL", "0")); } else { string com3 = "select distinct ast_loc_zone , ast_loc_zone from ast_loc (nolock) where ast_loc_state = '" + DropDownState.SelectedItem.Text + "'"; SqlDataAdapter adpt3 = new SqlDataAdapter(com3, con); DataTable dt3 = new DataTable(); adpt3.Fill(dt3); DropDownZone.DataSource = dt3; DropDownZone.DataBind(); DropDownZone.DataTextField = "ast_loc_zone"; DropDownZone.DataValueField = "ast_loc_zone"; DropDownZone.DataBind(); DropDownZone.Items.Insert(0, new ListItem("ALL", "0")); } /*For District Dropdown Load*/ string com1 = "select RowID , ast_loc_ast_loc from ast_loc (nolock) where ast_loc_state = '" + DropDownState.SelectedItem.Text + "'"; SqlDataAdapter adpt1 = new SqlDataAdapter(com1, con); DataTable dt1 = new DataTable(); adpt1.Fill(dt1); DropDownDistrict.DataSource = dt1; DropDownDistrict.DataBind(); DropDownDistrict.DataTextField = "ast_loc_ast_loc"; DropDownDistrict.DataValueField = "RowID"; DropDownDistrict.DataBind(); DropDownDistrict.Items.Insert(0, new ListItem("ALL", "0")); string Com2 = "select RowID , ast_loc_circle from ast_loc (nolock) where ast_loc_state = '" + DropDownState.SelectedItem.Text + "'"; SqlDataAdapter adpt2 = new SqlDataAdapter(Com2, con); DataTable dt2 = new DataTable(); adpt2.Fill(dt2); DropDowncircle.DataSource = dt2; DropDowncircle.DataBind(); DropDowncircle.DataTextField = "ast_loc_circle"; DropDowncircle.DataValueField = "RowID"; DropDowncircle.DataBind(); DropDowncircle.Items.Insert(0, new ListItem("ALL", "0")); } catch (Exception ex) { //log error //display friendly error to user string msg = "Insert Error:"; msg += ex.Message; } }