Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create New Item via DataGridView using MVC Objects

Status
Not open for further replies.

eb24

Programmer
Dec 17, 2003
240
US
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:
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;
}
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top