hye...my scenario like this...i have 2 drop down list.... when user select the first ddp list...the value in the second value will be change according the selected value in the first ddp list... my first ddl list is package type ex;nature,island...and my second ddp list listed the location... when the user select value nature...then the second ddp list will list the location which include the package type = nature only.....
coding :
//this code for my first ddl list
private void Fill_ddladdpackagestypes()
{
OleDbCommand cmd = new OleDbCommand(
"SELECT package_type FROM package_master",
con);
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
ddladdpackagestypes.Items.Add(Convert.ToString(dr.GetValue(0)));
}
dr.Close();
con.Close();
}
//this code for my second ddp list
private void Fill_location()
{
string strConn = Application["tourism_Connection"].ToString();
SqlConnection con =
new SqlConnection(strConn);
string cmd = "SELECT location_name FROM package_location WHERE package_type = '" + Convert.ToString(ddladdpackagestypes.SelectedValue) + "'";
SqlCommand cmd2 =
new SqlCommand(cmd, con);
con.Open();
SqlDataReader dre = cmd2.ExecuteReader();
while(dre.Read())
{
ddlLocation2.Items.Add(Convert.ToString(dre.GetValue(0)));
}
dre.Close();
con.Close();
}
Please help me....
Enter your message below
Sign in or Join us (it's free).