I have a databound DropDownList which i need c# code to check the selected value is there or not.
ASP Code:
C# Code:
string BillCountryId = reader["BillCountryId"].ToString();
TextBox1.Text = BillCountryId;
ListItem li = countriesDropDownList.Items.FindByValue(BillCountryId);
if (li != null)
countriesDropDownList.SelectedValue = BillCountryId;
Problem is, its not finding any values which have been DataBound, only the (-1) of the 'Please Select' value. The C# Code is in the Page_Load void ..
Please help! :)
DavidPosted Jan 10, 2008, 6:12 AM
Thanks, thats got it!
Mike GoldPosted Jan 9, 2008, 6:25 PM
move the findbyvalue code from page_load to the DropDown DataBound event.