Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reset Combo To Saved Value
Message
De
15/01/2010 10:32:22
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01441946
Message ID:
01444143
Vues:
35
>I have a combobox bound to a dataset retrieved from table A. When the user selects an item, I store the SelectedValue to another table, say table B. The next time the app is run, I want that saved item displayed in the combo. How do I make this happen?

That's the normal way ComboBoxes work. You accomplish this with databinding. ComboBoxes have "complex" binding ... IOW, they have a DataSource (and DisplayMember and ValueMember) that shows up in the Combo's dropdown. But, you also need to databind the SelectedValue to something else in order to save it:
MyCombo.DataSource = ds.Tables["TableA"];
MyCombo.DisplayMember = "description";
MyCombo.ValueMember   = "code";

MyCombo.DataBindings.Add("SelectedValue", ds.Tables["TableB"], "MyCode");
~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform