Mr. Arnold said:
Well, you're going to use link-sql-query to only bringing back an ID and
Description off the Entity for the table that's going to load the combox.
Then I suspect that you're going to need a class Bill.cs that has the
get/set properties for ID and Description files.
Then you're going to go into a foreach loop, creating a new Bill each
time in the loop populating Bill and adding Bill to a List<Bill>.
That would be var bills = new List<Bill>(); that you would load Bill
into the collection of bills.
Then you'll take bills and bind it to the control.datasource.
I'll assume you know how to use the ComboBox Selection event and get the
selected line's ID.
Then you take the selected ID to do another link-2-sql query to select
the record by ID.
var hit = (from a in table where a.ID == ID select a).First();
hit.Name if name is a field on the table can be selected.
Textbox1.Text = hit.Name
That's how I would do it.
You completely lost me after you said that I'm "going to need a class
Bill.cs ...".
You must have missed that I'm using LinqToSql? Or maybe I'm somehow
using it differently than you?
When using LinqToSql, it will auto-magically generate a whole set of
classes that mirror the schema of the backend data. The IDE does that
when you drag-n-drop tables onto the designer.
It creates a class that inherits from System.Data.Linq.DataContext and
each time you add a new table, it will generate code for a new property
to return a generic list of table rows defined by a class that it also
generates code for. So, the classes are all there and I should NOT need
to create a "Bill" class to populate the combo.
Can you provide some examples of how to code the XAML? Particularly the
attributes "DataContaxt", "ItemsSource", "DisplayMemberPath",
"SelectedItem", etc.
Also, I'm creating a UserControl that will have a grid that will contain
all the UI widgets. How would I code the XAML for <ObjectDataProvider>
with the <UserControl.Resources> so that all controls on the grid have
the same DataContext?
Thanks,
Bill