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 );
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