Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2005

Tip: Looking for answers? Try searching our database.

Complicated Data Binding Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Elliott - 03 Jul 2005 02:40 GMT
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  | +--------+----------------------------+  |
| +--------------+                                          |
+-----------------------------------------------------------+
TaylorMichaelL - 04 Jul 2005 04:31 GMT
The Binding class along with the DataBindings property of Windows Forms was
designed for situations like this.  Basically you bind specific values to the
various controls using the same Binding.  The underlying currency manager
ensures that all the controls stay in sync.  If you change the position of
the binding within one control the other controls sharing the same binding
automatically change position as well.  Refer to the Binding class and
CurrencyManager for links to samples on how to get this stuff working.

Michael Taylor - 7/3/05

> 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.
[quoted text clipped - 50 lines]
> | +--------------+                                          |
> +-----------------------------------------------------------+
Dave - 05 Jul 2005 12:20 GMT
Yes, I realize that.  I stated that I had binding already working.

What I want to know is...
Given an item selected in listbox1 how to lookup all the AddressIDs in
Person2Addr and bind only those records from Address to ListBox2.

Cheers,
Dave

> The Binding class along with the DataBindings property of Windows Forms was
> designed for situations like this.  Basically you bind specific values to the
[quoted text clipped - 60 lines]
> > | +--------------+                                          |
> > +-----------------------------------------------------------+
rythm - 28 Sep 2005 20:56 GMT
You could use DataBinding.  I am assuming that either you are using Typed
DataSet or atleast know how to create Relationships.
Create the following Relationships:
PersonToPerson2Addr (Link the Person Table to Person2Addr Table)
Person2AddrToAddress  (Link the Person2Addr Table to Address Table)
Try this.

DataGrid1.SetDataBinding(dsDataSet.tbl_Person, "");
DataGrid2.SetDataBinding(dsDataSet.tbl_Person,
"PersonToPerson2Addr.Person2AddrToAddress");

The code above will make sure that when you change a selection in DataGrid1,
only the related information will be shown in DataGrid2.   Also this is not
just limited to DataGrids (Check the spellings, I might be a little of, do
not have the IDE to make sure).

--rythm

 Person      |    | Person2Addr  |    |  Address

> 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.
[quoted text clipped - 50 lines]
> | +--------------+                                          |
> +-----------------------------------------------------------+

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.