Possible to show 1 to many child data in individual controls??

  • Thread starter Thread starter StevenVibert
  • Start date Start date
S

StevenVibert

I'm working with a SQL database that includes 2 tables; Employees and
EmergencyContacts. The Employees table has an EmployeeID primary key,
the EmergencyContacts has a EmployeeID foreign key. Each employee can
have n emergency contacts.

Using ADO.NET with C# I can easily display this parent/child
relationship using individual controls to display the Employee data and
a DataGrid to show the associated EmergencyContacts.

What I'd like to do, however is the following: Rather than present the
Emergency Contacts Information in a DataGrid, I'd like to show this
data on a seperate TabPage in individual controls. Since it's likely
that there will be more than one EmergencyContact per Employee, this
TabPage would have record navigation controls.

For the life of me I have been unable to get this to work. When my app
initially fills the Employee and EmergencyContact DataAdapters, the
EmergencyContact information for the first record is correct. However,
when I navigate to another employee record the emergency contact
information for the employee is not updated (the info displayed is the
first employee's).

I'm having a tough time wrapping my head around what I need to do to
get this working.

Any thoughts, suggestions, and comments would be greatly appreciated.
Thanks!
Steve
 
when I navigate to another employee record the emergency contact
Okay I assume by navigate you mean "navigate using the record navigation
controls".

Try this - add an event that on text change, you refocus on the appropriate
control the text was edited in. It's weird how databinding works, I don't
remember the exact event, but the dataset doesn't get updated until you
actually leave the field (or something like that). Sorry it's late at night,
and I need to sleep :-), but the answer lies in hooking on an extraneous
event to the textbox on text change. That'd ensure that the underlying
dataset gets updated.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
Thanks for the reply. Yes, I mean "navigate using the record
navigation
controls". I tried your suggestion and set up eventhandlers for
TextChanged and ModifiedChanged. The only time the TextChanged event
fires is the first time the app loads and the first record is
displayed. It never fires again when I navigate from record to record.
The ModifiedChanged event never fires.

Is what I'm trying to do even possible using databinding?
Thanks -- Steve
 
Back
Top