Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
YAQ on DropDownList
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01119321
Message ID:
01119325
Vues:
21
This message has been marked as the solution to the initial question of the thread.
>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?

Dmitry;

Does this work for you?
ddlSite.SelectedIndex = ddlSite.Items.IndexOf(ddlSite.Items.FindByValue(MyString));
Tom
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform