Linked Forms

Docs

Instances of DbNetEditCore can be linked together to create parent child relationships. To link a child edit simply add it to the parent control using the AddLinkedControl method. The edit controls are linked by automatically associating the column in the child edit control specified as a ForeignKey with the column in the parent Edit identified as a PrimaryKey (usually automatic). This sample also demonstrates how to use custom HTML markup by specifyng the Id of the containing element as a 3rd argument to the constructor.

Customers

Orders

Order Details

Razor
                                
                                        
DbNetEditCore orderDetailsEdit = new DbNetEditCore("northwind", "[order details]", "orderDetailsEdit");
orderDetailsEdit.Column("OrderID").ForeignKey().Hidden();
orderDetailsEdit.Column("ProductID").Lookup(new Lookup("Products", "ProductId", "ProductName")).Label("Product");
orderDetailsEdit.Column("UnitPrice").Format("c");
orderDetailsEdit.LayoutColumns = 3;

DbNetEditCore ordersEdit = new DbNetEditCore("northwind", "orders", "ordersEdit");
ordersEdit.Column("CustomerID").ForeignKey().Hidden();
ordersEdit.Column("EmployeeID").Lookup(new Lookup("Employees", "EmployeeId", "lastname + ',' + firstname")).Label("Employee");
ordersEdit.Column("ShipVia").Lookup(new Lookup("Suppliers", "SupplierId", "CompanyName"));
ordersEdit.Column("Freight").Format("c");
ordersEdit.LayoutColumns = 3;
ordersEdit.AddLinkedControl(orderDetailsEdit);

DbNetEditCore customersEdit = new DbNetEditCore("northwind", "customers", "customersEdit");

customersEdit.Column("CustomerID").Hidden();
customersEdit.AddLinkedControl(ordersEdit);
customersEdit.LayoutColumns = 3;

@customersEdit.Render()