In this tutorial we will show you how to setup Master/Detail table view in ASP.NET Maker. We will use the demo database for demonstration.
In the demo database, there are two tables called "Orders" and "Order Details". We will set up the master/detail relation between these two tables.
Fields in Table "Orders"
Fields in Table "Order Details"
Steps to Setup Master/Detail Records
1. Loading ASP.NET Maker
Open ASP.NET Maker and connect to the demo database.
2. Setting up Master/Detail Relationship
Select either the master or detail table in the Database tree view (the left pane). In this example, we choose the master table - "Orders" table. Then we select the Table tab in the right pane.
Then in [Master/Detail] panel at the bottom right corner of the page, click [Modify...] to bring up the visual master/detail relationship editor. Drag the detail table from the table list on the left to the diagram on the right.
Then create a relationship between them by dragging from the master field (key field in master table) to the detail field (foreign key field in the detail table).
If there are more linked field, repeat the step until all the relationships are setup. In this tutorial, we only have one detail field ([Order Details].OrderID) and one master field (Orders.OrderID).
ASP.NET Maker supports multiple master/detail, if the table has other master tables or detail tables, just repeat above process. In this example, we have only one master/detail relationship, so we click [OK] to confirm. The master/detail relationship is setup.
If you want to enable Master/Detail-Add, Master/Detail-Edit and/or Master/Detail-View, enable them for the detail table in the Table Setup page:
If you have the Preview extension (for registered users only) and want to enable detail record preview by Ajax, you can click Tools->Extension to enable it. Also see Third-Party Tools.
Enable the extension and then click the Advanced tab to set your settings for each table:
3. Generating ASP.NET Script
Click the [Generate ASP.NET] icon to go to the [Generate] tab, click the [Generate] button. ASP.NET Maker will generate the required ASP.NET scripts automatically.
4. Running the ASP.NET Application
Click on the link to the "orders" table, there will be a new column for the "orderdetails " table. Click on the "orderdetails" button to access the order details for the selected record. Click the down arrow button and then click Master/Detail View, Master/Detail Edit or Master/Detail Copy to view/edit/copy and selected record and its detail records.
If you have enabled Preview extension and enable PreviewOverlay, move your mouse cursor over the "orderdetails" button and you'll see detail records preview:
If you have enabled Preview extension and enable PreviewRow, click the [+] button in the row and and you'll see the preview row:
Click the Master/Detail View link/button, the View page of the master table with a detail table grid of the detail table will be shown.
Click the Master/Detail Edit link/button, the Edit page of the master table with a detail table grid of the detail table will be shown.
Click the Master/Detail Copy link/button, the Add page (in Copy mode) of the master table with a detail table grid of the detail table will be shown.
Click the Add orders/orderdetails button in the paging section, the Add page of the master table with a detail table grid of the detail table will be shown.