Öncelikle gözünüzün önündeki uyarıyı bile görmediğiniz için uzun süredir bilgisayar başında olduğunuzu tahmin ediyorum. Kalkın; biraz yürüyün, hem zihniniz hem ayaklarınız açılır. Sonra koda tekrar bakarız.
Eki Görüntüle 1775521
Biraz öyle oldu hocam,
namespace WebApplication4
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ulkeDropDownList.Items.Add("Türkiye");
ulkeDropDownList.Items.Add("Almanya");
}
}
protected void ulkeDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
ilDropDownList.Items.Clear();
ilceDropDownList.Items.Clear();
if (ulkeDropDownList.SelectedIndex == 0)
{
ilDropDownList.Items.Add("İstanbul");
ilDropDownList.Items.Add("Sakarya");
}
if (ulkeDropDownList.SelectedIndex == 1)
{
ilDropDownList.Items.Add("Berlin");
ilDropDownList.Items.Add("Köln");
}
}
protected void ilDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
ilceDropDownList.Items.Clear();
if (ilDropDownList.SelectedIndex == 0 && ulkeDropDownList.SelectedIndex == 0) // il 0 yani istanbul, ülke 0 yani türkiye
{
ilceDropDownList.Items.Add("Tuzla");
ilceDropDownList.Items.Add("Maltepe");
}
if (ilDropDownList.SelectedIndex == 1 && ulkeDropDownList.SelectedIndex==0 ) // il 1 yani sakarya, ülke 0 yani türkiye
{
ilceDropDownList.Items.Add("Serdivan");
ilceDropDownList.Items.Add("Karasu");
}
if (ilDropDownList.SelectedIndex == 2 && ulkeDropDownList.SelectedIndex == 1)// il 2 yani berlin, ülke 1 yani almanya
{
ilceDropDownList.Items.Add("berlinilce1");
ilceDropDownList.Items.Add("berlinilce2");
}
if (ilDropDownList.SelectedIndex == 3 && ulkeDropDownList.SelectedIndex == 1)// il 3 yani berlin, ülke 1 yani almanya
{
ilceDropDownList.Items.Add("kölnilce1");
ilceDropDownList.Items.Add("kölnilce2");
}
}
}
}