all groups > dotnet windows forms databinding > april 2008 >
You're in the

dotnet windows forms databinding

group:

Changing a One-To-Many form to a One-To-One Form



Changing a One-To-Many form to a One-To-One Form Terry
4/17/2008 6:43:42 AM
dotnet windows forms databinding: Microsoft has a 5 minute video showing how to create a one-to-many
form using drag and drop controls from the Data Sources window.
(http://msdn2.microsoft.com/en-us/vbasic/bb643827.aspx). I=92m trying
to create almost the exact same form, except for one small change.
Instead of dragging the many table onto the form as a DataGridView, I
drag it onto the form as a Details view. This gives me individual
fields instead of a DataGridView for the child records. The
relationship between my two tables is really one to one, and so I
really only want to add a single related record. (Yes, I have good
reasons for this one-to-one relationship.)

What I expected to happen is that when I add a new record to the
parent table (using the + sign on the BindingNavigator toolbar) and
then clicked on a field from the child table, the key value from the
parent table would fill in the foreign key field of the child table
automatically, just as it does when you click in a field inside the
DataGridView from the video demo. This doesn=92t happen, and therefore
I am unable to save the related child record. I spent a whole day
trying to figure out how to work with this one-to-one relationship
without success.

Any help on how to handle this one-to-one relationship would be
AddThis Social Bookmark Button