Comboboxtan il seçince diğer comboboxa bu ile ait ilçeleri listeletemiyorum,hata alıyorum.
Son Düzenleme: 15/12/2013, 22:44, Düzenleyen: alican60.
converter.telerik.com
private void IlleriComboyaYukle()
{
OleDbConnection baglanti = new OleDbConnection ("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Application.StartupPath + "\\iller.mdb");
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM tblIl", baglanti);
DataTable dt = new DataTable();
da.Fill(dt);
cbIl.DataSource = dt;
cbIl.ValueMember = "ilId";
cbIl.DisplayMember = "ilAdi";
}
private void IlceleriComboyaYukle(int IlId)
{
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Application.StartupPath + "\\iller.mdb");
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM tblIlce WHERE ilId=" + IlId, baglanti);
DataTable dt = new DataTable();
da.Fill(dt);
cbIlce.DataSource = dt;
cbIlce.ValueMember = "ilceId";
cbIlce.DisplayMember = "ilceAdi";
}
private void Form1_Load(object sender, EventArgs e)
{
IlleriComboyaYukle();
}
private void cbIl_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
IlceleriComboyaYukle(Convert.ToInt32(cbIl.SelectedValue.ToString()));
}
catch{}
}