Linked Grid

Docs

Instances of DbNetGridCore can be linked to a form control. To link a child grid 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

Razor
                                
                                        
DbNetGridCore ordersGrid = new DbNetGridCore("northwind", "orders", "ordersGrid")
{
    Columns = new List{ "OrderID", "CustomerID", "EmployeeID", "OrderDate", "RequiredDate", "ShippedDate", "Freight", "ShipVia" },
    Insert = true,
    QuickSearch = true,
    Delete = true,
    Update = true
};

ordersGrid.Column("CustomerID").ForeignKey();
ordersGrid.Column("EmployeeID").Lookup(new Lookup("Employees", "EmployeeId", "lastname + ',' + firstname")).Label("Employee");
ordersGrid.Column("ShipVia").Lookup(new Lookup("Shippers", "ShipperId", "CompanyName"));
ordersGrid.Column("Freight").Format("c");

DbNetEditCore customersEdit = new DbNetEditCore("northwind", "customers", "customersForm")
{
    Columns = new List{ "CustomerID", "CompanyName", "Address", "City" },
    Insert = true,
    QuickSearch = true,
    Delete = true
};

customersEdit.Column("CustomerID").Hidden();
customersEdit.AddLinkedControl(ordersGrid);

@customersEdit.Render()