Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reset Combo To Saved Value
Message
From
15/01/2010 10:32:22
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01441946
Message ID:
01444143
Views:
36
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform