Datasheet
❑ PagerStyle: Defines the style of the pager section. In our grid, this is the last row showing the
page numbers, but it appears before the footer if a footer row is being shown.
❑
FooterStyle: Defines the style of the footer row. In our grid, we aren't showing a footer, but
the style is set so that the footer will look correct if it is shown.
❑
SelectedItemStyle: Defines the style of items when they are selected. Our grid isn't selectable
by default, but like the
FooterStyle the default style is set in case item selection is added.
❑
ItemStyle: Defines the style for each row of data in the grid.
❑
HeaderStyle: Defines the style for the header row, where the column names are shown.
That's all there is to this example – two controls that are linked together. When the page is loaded, the
AccessDataSourceControl connects to the database and runs the command. The MxDataGrid then
fetches the data stored by the data source control and constructs a grid around it. In fact, the grid is the
most complex piece of code here because of all the properties being set - purely to change the look. At its
simplest, you could have the following:
<wmx:MxDataGrid id="MxDataGrid2" runat="server"
DataSourceControlID="AccessDataSourceControl2">
</wmx:MxDataGrid>
This only contains the attributes required to display data.
Displaying Data Using the Web Matrix Template Pages
You've probably noticed a number of template pages when you add a new page in Web Matrix – some of
those are for data reports. These provide a simple way to get more functionality into grids than the
example earlier used.
The supplied template pages are as follows:
❑
Simple Data Report: Gives a simple grid without paging or sorting
❑ Filtered Data Report: Gives a grid with a filter option, so you can select the rows displayed
❑ Data Report with Paging: Gives a grid with paging enabled
❑ Data Report with Paging and Sorting: Gives a grid with paging and column sorting enabled
❑ Master – Detail Grids: Gives two grids, representing a master table and a child table
❑ Editable Grid: Gives a grid allowing updates to the data
❑ Simple Stored Procedure: Gives a grid that uses a stored procedure for its data source
All of these supplied templates connect to a SQL Server database, and need modification if they are to be
used with a different database. However, they provide a quick way to get pages constructed, allowing
you to make a few simple changes to get what you need, rather than coding from scratch.
Let's look at one of these - the report with paging and sorting.
256
Chapter 8
57084_08.qxp 30/01/2004 8:03 PM Page 256