Hi EveryOne
Here is the newer version of the problem i discussed and was solved with all your help.
I now have 3 DropDownLists. Now the idea is the same I populated the first DropDownList on PageLoad. Then OnSelectedIndexChanged i popolated the second one. Then on selection on the second one i populated the third one.
[PROBLEM] The problem is the same that the second DropDownList is now doubling and trippling the seleted items. I mean it concatenates the new items with the old ones, even the searching criteria is changed. I tries DropDownList7.Items.Clear(), but it is not working.
Here is the sample code i m trying to run.
void Page_Load(Object s,EventArgs e)
{
objConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("/") + "aeg.mdb");
objConn.Open();
objCmd = new OleDbCommand("SELECT DISTINCT Country from Institutes",objConn);
objReader = objCmd.ExecuteReader();
if(! IsPostBack)
while(objReader.Read())
{
DropDownList6.Items.Add(Convert.ToString(objReader["Country"]));
}
}
Then on Selected Index change:
void DropDownList6_SelectedIndexChanged(object sender, EventArgs e) {
objCmd = new OleDbCommand("SELECT DISTINCT City from Institutes where Country = '"+ DropDownList6.SelectedItem.Text + "'",objConn);
objReader = objCmd.ExecuteReader();
while(objReader.Read())
{
DropDownList7.Items.Add(Convert.ToString(objReader["City"]));
}
}
void DropDownList7_SelectedIndexChanged(object sender, EventArgs e) {
objCmd = new OleDbCommand("SELECT DISTINCT Institute from Institutes where Country = '"+ DropDownList6.SelectedItem.Text + "' and City = '" + DropDownList7.SelectedItem.Text + "'",objConn);
objReader = objCmd.ExecuteReader();
while(objReader.Read())
{
DropDownList8.Items.Add(Convert.ToString(objReader["Institute"]));
}
}