Sep 18, 2009, 8:33 AM
Populating Combo Box based on other combo box
I m using two Coolite combo boxes- cmbCountry and cmbStates.
I've filled the cmbCountry with country names while page loads.
I want to populate "cmbStates" with names of states of perticular country that is selected in cmbCountry.
I am using all data from tables.
Used cmbStates.Items.Add to add the states' names.
Written the code to populate/add states in cmbStates in Change event of cmbCountry.
I have used data table "mDtTbl" to fill values in both the comboboxes.
While debuging it shows that values are coming in cmbStates, but not displaying in.
is there any setting needed like "postback" to get the work done?
Any help..?
I've filled the cmbCountry with country names while page loads.
I want to populate "cmbStates" with names of states of perticular country that is selected in cmbCountry.
I am using all data from tables.
Used cmbStates.Items.Add to add the states' names.
Written the code to populate/add states in cmbStates in Change event of cmbCountry.
I have used data table "mDtTbl" to fill values in both the comboboxes.
if (mDtTbl.Rows.Count > 0)
{
for (int i = 0; i <= mDtTbl.Rows.Count - 1; i++)
{
mCombo.Items.Add(mDtTbl.Rows[i][0].ToString());
}
}
CmbCountry is filled in and displaying country names properly.While debuging it shows that values are coming in cmbStates, but not displaying in.
is there any setting needed like "postback" to get the work done?
Any help..?
Last edited by geoffrey.mcgill; Feb 21, 2011 at 10:13 PM.