<div id="Grid1"></div>
@using DbNetLink.DbNetSuite.UI
@{
    DbNetGrid Grid = new DbNetGrid();
    Grid.ConnectionString = "SamplesDatabase";
    Grid.PageSize = 10;
    Grid.FromPart = "Employees";
    Grid.ID = "Grid1";
    Grid.Theme = Themes.Bootstrap;
        
    Grid.ToolbarButtonStyle = DbNetLink.DbNetSuite.Shared.ToolButtonStyles.ImageAndText;

    string[] Columns = { "EmployeeID","LastName","FirstName","Title","TitleOfCourtesy","BirthDate","HireDate","Address","City","Region","PostalCode","Country","HomePhone","Extension","ReportsTo"  };
    
    foreach (String Column in Columns)
    {
        GridColumn C = Grid.GridColumns.Add(Column);
        
        switch(Column)
        {
            case "ReportsTo":
                C.Lookup = "select EmployeeID, FirstName + ' ' + LastName from Employees";
                break;
            case "EmployeeID":
                C.PrimaryKey = true;
                break;                       
        }
    }

    DbNetGrid NestedGrid = new DbNetGrid();
    NestedGrid.ConnectionString = "SamplesDatabase";
    NestedGrid.PageSize = 10;
    NestedGrid.FromPart = "Employees";
    NestedGrid.ID = "NestedGrid1";
    NestedGrid.Theme = Themes.Bootstrap;
    NestedGrid.OrderBy = "EmployeeID";
    NestedGrid.ToolbarLocation = DbNetLink.DbNetSuite.GridEditControl.ToolbarOptions.Hidden;
    NestedGrid.ToolbarButtonStyle = DbNetLink.DbNetSuite.Shared.ToolButtonStyles.ImageAndText;

    string[] NestedColumns = { "EmployeeID", "Photo", "Notes"};

    foreach (String Column in NestedColumns)
    {
        GridColumn C = NestedGrid.GridColumns.Add(Column);

        switch (Column)
        {
            case "EmployeeID":
                C.PrimaryKey = true;
                C.Display = false;
                break;
        }        
    }

    Grid.NestedGrid = NestedGrid;
                                             
    @Html.Raw(DbNetLink.DbNetSuite.UI.MVC.Render(Grid));
}
;