Datasheet

Figure 8-5
Amazing! A sortable grid full of data and you didn't have to write even a single line of code!
How It Works
Its workings rely on two controls: the AccessDataSourceControl, which provides the connection to
the database, and an
MxDataGrid, which is a Web Matrix control (also covered in Chapter 10) that
displays the data. Looking at the HTML view for these controls gives you a good idea of what they do.
Let's start with the
AccessDataSourceControl:
<wmx:AccessDataSourceControl id="AccessDataSourceControl2"
runat="server" SelectCommand="SELECT * FROM [Suppliers]"
ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4;
Data Source=C:\BegASPNET11\data\Northwind.mdb"></wmx:AccessDataSourceControl>
The first thing to notice is the way the control is declared. You're used to seeing asp: at the beginning of
controls, but not
wmx:. This prefix is the namespace – remember in the previous chapter where we said
that namespaces provide a separation between classes. In this case, these controls are part of Web
Matrix, and have thus been given a different namespace from the standard server controls.
Apart from the
id and runat, there are two other attributes that provide the details regarding which
database to connect to and what data to fetch:
257
Reading From Databases
57076_Ch 8 SAN.qxd 01/12/2003 6:43 PM Page 257