Datasheet

some database specific features. You don't need to know about these specifically (they are fully
documented in the .NET help files); just copy them if you ever need to use them again.
At this stage, you have enough details to connect to a database and fetch data, but don't have any way to
display it. For that we are going to use the
MxDataGrid control:
<wmx:MxDataGrid id="MxDataGrid2" runat="server"
DataSourceControlID="AccessDataSourceControl2" BorderColor="#CCCCCC"
AllowSorting="true" DataMember="Suppliers" AllowPaging="true"
BackColor="White" CellPadding="3" DataKeyField="SupplierID"
BorderWidth="1px" BorderStyle="None">
<PagerStyle horizontalalign="Center" forecolor="#000066"
backcolor="White" mode="NumericPages"></PagerStyle>
<FooterStyle forecolor="#000066" backcolor="White"></FooterStyle>
<SelectedItemStyle font-bold="true" forecolor="White"
backcolor="#669999"></SelectedItemStyle>
<ItemStyle forecolor="#000066"></ItemStyle>
<HeaderStyle font-bold="true" forecolor="White"
backcolor="#006699"></HeaderStyle>
</wmx:MxDataGrid>
This may seem complex but is actually very simple. Let's look at all of the attributes:
As part of the grid, we also have some style elements:
Attribute Description
DataSourceControlID
This contains the ID of the data source control from
which data will be fetched. In this case, it's the ID of
the AccessDataSourceControl we described
earlier.
BorderColor
This is the color of the grid border.
AllowSorting
Indicates whether or not the grid will support sorting.
DataMember
This contains the database table name.
AllowPaging
Indicates whether or not the grid supports paging.
The default number of rows in a page is 10, and this
can be changed with the PageSize attribute.
BackColor
This is the background color for the grid.
CellPadding
This defines the amount of padding between grid
cells. A higher number means the cells will be spaced
further apart.
DataKeyField
This is the primary key of the table.
BorderWidth
This is how wide the border of the grid is. Here it is 1
pixel (px stands for pixel), which is a thin border.
BorderStyle
This is the style of the border.
255
Reading from Databases
57084_08.qxp 30/01/2004 8:03 PM Page 255