In my C# 2.0 Windows App, we are using the MVC pattern with everything bound to business objects. I have been creating UserControls where they might have 2-3 DataGridViews on them w/ Parent-Child-GrandChild relationships between them. For testing purposes, I have an initial form that feeds one of these UserControls a ParentID. Upon loading this UserControl, I get the pertinent data, e.g. GetData(ParentID), and populate the UserControl's grids. For the actual DataGridViews on the UserControl, the way I've been Creating new items (Child) is via something like this:
This works great because both ParentObject and ChildObject reside in the UserControl.
My question is: how can I create a new item given a ParentID coming in from another Form and technically another type of Parent, i.e. w/o the ParentObject class but with the ParentObject's unique identifier (ParentID)? Hopefully the aforementioned makes sense.
Any and all assistance will be greatly appreciated.
Code:
private ChildObject AddChildItem()
{
ParentObject parent = (ParentObject)ParentBindingSource.Current;
ChildObject child = new ChildObject(parent);
ChildObjectController.Create(child);
parent.ChildObject.Add(child);
ChildCollectionBindingSource.ResetBindings(false);
return child;
}
My question is: how can I create a new item given a ParentID coming in from another Form and technically another type of Parent, i.e. w/o the ParentObject class but with the ParentObject's unique identifier (ParentID)? Hopefully the aforementioned makes sense.
Any and all assistance will be greatly appreciated.