Hi friends.
I want to bind country,state,city to combobox.what i have done is country name has been bound to combobox1 at the page_load event. The below code for binding country on the page load event
stage(1)
int i = 3;
DataTable dt = ibl2.combo1(i);
countrycombo.DataSource = dt;
countrycombo.DisplayMember =Convert.ToString( dt.Columns["Country_name"]);
countrycombo.ValueMember = Convert.ToString(dt.Columns["Country_id"]);
country name successfully bound to contrycombobox.
stage(2)
The below code for bind statename at combobox1_selectedIndexChandged event
private void countrycombo_SelectedIndexChanged(object sender, EventArgs e)
{
string countyname = Convert.ToString( countrycombo.SelectedItem);
DataTable ds = ibl2.statecombo(countyname);
statecombo.DataSource = ds;
if (ds != null)
{
statecombo.DisplayMember = Convert.ToString(ds.Columns["State_name"]);
statecombo.ValueMember = Convert.ToString(ds.Columns["State_id"]);
}
The problem occurrs on the second stage.Binding the state name to combobox2(statecombo) based on the country name.
The problem is when binding the statename to combobox2 at the combobox1_selectedIndexchanged event it take null value from country name.when i trace this process using f11 key, combox1_selectedItem event occur after the code
countrycombo.DataSource = dt;
in the page load itself so that it doesnt take any value from country combo box. what i need is this event should be occur after when i select the name of the country. what can i do.