Two dropdownlist (drpcountry & drp city). i just want if i select pakistan in drpcountry other dropdownlist which is drpcity should display cities of that country it works for 1st country pk but if i select other the cities drp list dont update and show same old cities. i have true autopostback in both dropdownlist and code is below
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack==false)
{
drpcountry.Items.Add("Pakistan");
drpcountry.Items.Add("Iran");
drpcountry.Items.Add("Dubai");
drpcity.Items.Add("Islamabad");
drpcity.Items.Add("Karachi");
drpcity.Items.Add("Lahore");
}
}
protected void drpcountry_change(object sender, EventArgs e)
{
drpcity.Items.Clear();
if (drpcountry.SelectedItem.Value == "Pakistan")
{
drpcity.Items.Add("Islamabad");
drpcity.Items.Add("Karachi");
drpcity.Items.Add("Lahore");
}
else if (drpcountry.SelectedItem.Value == "Iran")
{
drpcity.Items.Add("Tehran");
drpcity.Items.Add("Muskat");
drpcity.Items.Add("Damishq");
}
else
{
drpcity.Items.Add("Doha");
drpcity.Items.Add("zaibi");
drpcity.Items.Add("inshalla go there");
}
}
}
Software/Hardware used:
ASKED:
June 28, 2009 8:49 AM
UPDATED:
June 29, 2009 12:45 PM