Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Preselect a value in a DropDown list
Message
De
28/07/2003 10:56:21
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Preselect a value in a DropDown list
Divers
Thread ID:
00814120
Message ID:
00814120
Vues:
46
I'm using ASP.Net to create a Webform. My Webform contains a State drop down list. I populate the drop down with values from my state.dbf table.

The Webform is an editing form that allows you to modify an employee's information. How can I preselect the correct state in the drop down list based on the current employee's state value?

The SelectedIndex works if you know the row, but what if you only know the character value such as 'OH'?

Here's how I populate the state drop down:
this.cbo_loc.DataTextField = "cstate";  //From state.dbf.
this.cbo_loc.DataValueField = "cstate"; //From state.dbf.
this.cbo_loc.DataSource = myDS;
//this.cbo_loc.SelectedIndex = 2;  //This will work but I only know the char value.
this.cbo_loc.DataBind();
Thanks,

Jerry
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform