Two methods come to mind:
You can use Contains like this:
if (ddlCustomerNumber.Items.Contains(new ListItem(GetCustomerNumberCookie().ToString()))) {
or change the current strategy:
if (ddlCustomerNumber.Items.FindByText( GetCustomerNumberCookie().ToString()) != null) {
EDIT: There is also DropDownList.Items.FindByValue , which works the same as FindByText, except that it searches based on values.
Scott Anderson Jan 05 '10 at 16:03 2010-01-05 16:03
source share