Datasheet
259
Reading From Databases
Attribute Description
BorderWidth This is how wide the border of the grid is. Here it is 1 pixel (px stand
for pixel), which is a thin border.
BorderStyle This is the style of the border.
As part of the grid we also have some style elements:
❑
PagerStyle, which 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, which 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, which 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, which defines the style for each row of data in the grid
❑
HeaderStyle, which 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 contains just the attributes required to display data.
Displaying Data Using 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.
57076_Ch 8 SAN.qxd 01/12/2003 6:43 PM Page 259