ASP.NET Logo Back to WebMatrix Home

 
ASP.NET Pages with Data
Display Data with MxDataGrid
The MXDataGrid ASP.NET Web server control is specifically designed to display information from a data source. You can bind the control to a data source at design time or at run time. Although you can display data from a variety of data sources, the most typical sources are datasets and data views.

In this walkthrough, you will bind a MXDataGrid to the Orders table in the Orders database.

  1. Select File->New to get the "New File" dialog
  2. Select (General) from the Templates pane.
  3. Select the ASP.NET Page template.
  4. Type a file path in the Location box.
  5. Type myFirstDataGrid.aspx in the Filename box.
  6. Select Visual Basic in the Language drop-down box.
  7. Click OK

    New File Dialog

  8. The myFirstDataGrid.aspx file will open in Design view.

     
  9. Type "Orders Listing" into the page, then hit the Enter key to insert an empty space.

    Add Label To Page

  10. Select the Data tab in the Workspace window.

     
  11. Connect to the Orders database you developed earlier in this Guided Tour.

     
  12. Select the Orders table in the Tables node in the Data tree view.

     
  13. Drag the Orders table onto the ASP.NET page.

     
  14. You will see a SQLDataSourceControl and MXDataGrid appear on the ASP.NET page.

    Note ASP.NET Web Matrix automatically sets the properties of the SQLDataSourceControl based on the connection information specified when connecting to the database.

    Note ASP.NET Web Matrix automatically binds the MXDataGrid to the SQLDataSourceControl

    Add Orders Table To Page

     

  15. Save and run the ASP.NET page.

     
  16. Your ASP.NET page will automatically appear in a new instance of your Web browser. The MXDataGrid will show all of the rows in the Orders table.  If you have more than 10 rows of data in the database, then the MXDataGrid will automatically enable paging support to show only 10 rows of data at a time (and add navigation links for a user to browse back and forth within the table).

    Orders Data Page

  17. Close the Web browser instance.

Next Step >>