Complicated Data Binding Question

  • Thread starter Thread starter me
  • Start date Start date
M

me

I've included a picture below to show what I am trying to accomplish.
It is best to copy/paste into notepad to get the spacing correct.

I have a dataset that contains 3 tables. Two of the tables contain
data and the third links them together. The dataset has a constraint
setup as well.

The first listbox and the first and last name text box are bound to
the Person DataTable. As you select a name in the listbox, the
textbox will be updated with the appropriate name. You can make
modifications to the name and have them updated in the listbox.

This works just fine. Now for the problem.

I need to have the second listbox populated with entries that are
specific to the person that is selected in the first listbox. This
restriction prevents me from directly binding to the Address
DataTable. Once I have the filtered data , I will then need to have
the same editing capabilities as listed above.

Ideally, I would like to do databinding as I will be writing the
values back into the database. I'm just not sure how to filter and
bind at the same time.

If you have a code example somewhere or just a basic "here's what you
need to do" list or any thoughts on how to accomplish this, I would
love to hear about it.

Thanks,
Dave


+--------------+ +--------------+ +--------------+
| Person | | Person2Addr | | Address |
+--+-----------+ +--+-----------+ +--+-----------+
|PK| ID |>---|PK| PersonID |---<|PK| ID |
| | LastName | |PK| AddressID | | | City |
| | FirstName | +--+-----------+ | | State |
+--+-----------+ +--+-----------+



+-----------------------------------------------------------+
| +------------+ +------------+------------------------+ |
| | Listbox | | First Name:| Jane | |
| +------------+ +------------+------------------------+ |
| | Smith,Jane | | Last Name: | Smith | |
| | Smith,John | +------------+------------------------+ |
| +------------+ |
| |
| +--------------+ +--------+----------------------------+ |
| | Listbox | | City: | St. Louis | |
| +--------------+ +--------+----------------------------+ |
| | St.Louis, MO | | State: | MO | |
| | Raleigh, NC | +--------+----------------------------+ |
| +--------------+ |
+-----------------------------------------------------------+
 
Me,

You can in my opinion use two approaches (I only declare the second)
You can set a relation, however the most simple one in my opinion is to set
in the index change event the datasource of your second listbox to a
defaultview (dataview) with a rowfilter.

Be aware that you have to protect that event at loading time from taking
action.

Altough, if I understand your well, than I would take a datagrid and not a
listbox for the second. From that datagrid you can using the defaultview
(dataview) remove a lot of editing possibilities and you can remove as well
as the so called left header. With what the datagrid becomes a kind of
multicolumn editable listbox.

I hope this gives an idea, otherwise reply?

Cor
 
I don't see how using a datafilter will get me there.

If "Jane Smith" has 20 addresses in the address table, there would be
20 entries in the person2addr table as well.

I would have to lookup in the person2addr table for all the AddressIDs
that match the ID of "Jane Smith". From there I would have to create
the filter using the 20 AddressIDs that were returned. I'm not sure
that is feasible.

If I am missing something please let me know.

Thanks,
Dave
 
Dave,
If "Jane Smith" has 20 addresses in the address table, there would be
20 entries in the person2addr table as well.

From your first message I did not understand that you not are using a
primary key. If that is the fact, how do you than want to handle that
problem as you describe above?

Cor
 
Back
Top