Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
YAQ on DropDownList
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
YAQ on DropDownList
Miscellaneous
Thread ID:
01119321
Message ID:
01119321
Views:
53
I am having a problem where code does not find an item in a DropDownList (DDL):

If I scan items in the drop down list as following:
for (int i =0;i < ddlSite.Items.Count ;i++ )
{		 
  Response.Write( ddlSite.Items[i].Value.ToString() );
}
I can clearly see the item.

But if I check for My item in code, nothing found. Here is an example:
string MyString = "ABC";
for (int i =0;i < ddlSite.Items.Count ;i++ )
{
  if ( ddlSite.Items[i].Value.ToString().Equals(MyString))
  {
     Response.Write("Bingo!" );
  }							
}
or if I do the following:
ListItem selectedItem = ddlSite.Items.FindByValue( MyString );
// here selectedItem is NULL
I never get Bingo. And as I mentioned, the DDL does have an item with value "ABC". What am I missing?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Next
Reply
Map
View

Click here to load this message in the networking platform