When the user navigates to a new page, this ddl\'s selected index is determined by a cookie, but if the ddl doesn\'t contain that cookie\'s value, then I\'d like it to be se
There are two methods that come to mind:
You could use Contains like so:
if (ddlCustomerNumber.Items.Contains(new
ListItem(GetCustomerNumberCookie().ToString())))
{
// ... code here
}
or modifying your current strategy:
if (ddlCustomerNumber.Items.FindByText(
GetCustomerNumberCookie().ToString()) != null)
{
// ... code here
}
EDIT: There's also a DropDownList.Items.FindByValue
that works the same way as FindByText, except it searches based on values instead.