Datasheet
❑ The SelectCommand defines the SQL that will return the required data – in this case, it's all
rows and columns from the
Suppliers table. This is the default since we dragged this table,
but we can customize the
SelectCommand to return only selected rows or columns.
❑ The
ConnectionString defines the OLEDB connection string. You only need to worry about
the bit with the path of the database file – the
Data Source bit (if you move the file, you'll
need to change this). The other parts of the
ConnectionString just define the type of database
and 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:
<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 seems complex but is actually very simple. Let's look at all of the attributes:
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.
258
Chapter 8
57076_Ch 8 SAN.qxd 01/12/2003 6:43 PM Page 258