Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Select DropDownList by Integer Value
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
How to Select DropDownList by Integer Value
Versions des environnements
Environment:
C# 2.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01361227
Message ID:
01361227
Vues:
66
Hi,

I have a drop down list on a page. The drop down list is bound to a DataView and the DataValueField is an integer field. I.e:
ddlSite.DataSource = dvSite;
ddlSite.DataTextField = "SITE_DESC";
ddlSite.DataValueField = "SITE_NO";  //  Integer field
ddlSite.DataBind();
Now I want to select an item of this drop down list by a certain integer value (e.g. 1). How do I select the drop down list by an integer value?

For example, if the DataValueField were a character type I would select as following (this one works):
string MyString = "123";
dlSite.Items.FindByValue( MyString ).Selected = true;
But when the DataValueField is Integer, I can't seem to find the correct syntax.

UPDATE:. Found solution. The same as with a character type string.
"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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform