B
ben
Hi All,
I have 3 dropdown lists which function as filters for the data being
passed into a datagrid...On Page load, the first drop downlist
populates with relevant data(using sql query), n now, depending on the
selection of the first drop down list, corresponding values get
populated into the second drop downlist, sort of like country, state,
city hierarchy...n depending on the selected index on 2nd, the 3rd ddl
gets populated, n then the datagrid is formed with that data....I have
tried placing the code to populate the second DDL in the
selectedindexchanged even of the first DDL and it does not work as
expected, i also have autopostback set to true so that it looks
dynamic to the user...this is some of the code(ddlcountry is the first
DDL
public void ddlcountry_SelectedIndexChanged(object sender,
System.EventArgs e)
{ string connstr=ConfigurationSettings.AppSettings["ConnectionString"];
string selectext="select ....where
g.cCountryID="+ddlcountry.SelectedItem.Value;
SqlConnection con1=new SqlConnection(connstr);
Response.Write(selectext);
SqlCommand mycommand2=new SqlCommand(selectext,con1);
con1.Open();
SqlDataReader dr1= mycommand2.ExecuteReader();
ddlstate.DataSource=dr1;
ddlstate.DataTextField="state";
ddlstate.DataValueField="cStateID";
ddlsubgroup.DataBind();
con1.Close();
dr1.Close();
}
Any help will be greatly appreciated !
Thanks in advance,
Ben
I have 3 dropdown lists which function as filters for the data being
passed into a datagrid...On Page load, the first drop downlist
populates with relevant data(using sql query), n now, depending on the
selection of the first drop down list, corresponding values get
populated into the second drop downlist, sort of like country, state,
city hierarchy...n depending on the selected index on 2nd, the 3rd ddl
gets populated, n then the datagrid is formed with that data....I have
tried placing the code to populate the second DDL in the
selectedindexchanged even of the first DDL and it does not work as
expected, i also have autopostback set to true so that it looks
dynamic to the user...this is some of the code(ddlcountry is the first
DDL
public void ddlcountry_SelectedIndexChanged(object sender,
System.EventArgs e)
{ string connstr=ConfigurationSettings.AppSettings["ConnectionString"];
string selectext="select ....where
g.cCountryID="+ddlcountry.SelectedItem.Value;
SqlConnection con1=new SqlConnection(connstr);
Response.Write(selectext);
SqlCommand mycommand2=new SqlCommand(selectext,con1);
con1.Open();
SqlDataReader dr1= mycommand2.ExecuteReader();
ddlstate.DataSource=dr1;
ddlstate.DataTextField="state";
ddlstate.DataValueField="cStateID";
ddlsubgroup.DataBind();
con1.Close();
dr1.Close();
}
Any help will be greatly appreciated !
Thanks in advance,
Ben