Lars_V_J
August 17th, 2009, 02:37 AM
In my code, I use this to set the values of two combos:
CB_BCountry.Items.FindByValue(resp.GetPersonResult.BirthCountryIdentifier.ToString()).Selected = true;
CB_Nationality.Items.FindByValue(resp.GetPersonResult.PrimaryNationlityIdentifier.ToString()).Selected = true;
This happens in a button click function.
If, however, I try to get the value by using
System.Web.UI.WebControls.ListItem item1 = CB_BCountry.SelectedItem;
string s1 = item1.Value;
System.Web.UI.WebControls.ListItem item2 = CB_Nationality.SelectedItem;
string s2 = item2.Value;
in another button click function, I *always* get the first item, no matter selection. If I do it in the Page_Load function, I get an error about not being allowed to select more than one item in a combobox.
I am extremely confused. How the h...do I properly get and set my current selection?
Thank you in advance.
CB_BCountry.Items.FindByValue(resp.GetPersonResult.BirthCountryIdentifier.ToString()).Selected = true;
CB_Nationality.Items.FindByValue(resp.GetPersonResult.PrimaryNationlityIdentifier.ToString()).Selected = true;
This happens in a button click function.
If, however, I try to get the value by using
System.Web.UI.WebControls.ListItem item1 = CB_BCountry.SelectedItem;
string s1 = item1.Value;
System.Web.UI.WebControls.ListItem item2 = CB_Nationality.SelectedItem;
string s2 = item2.Value;
in another button click function, I *always* get the first item, no matter selection. If I do it in the Page_Load function, I get an error about not being allowed to select more than one item in a combobox.
I am extremely confused. How the h...do I properly get and set my current selection?
Thank you in advance.