In Part 2 we looked at how to use ADO+ to read data into a
Dataset. Great. But now that we have that information in a
Dataset how can we
display it? We'll answer that question in this part!
OK, great, we have our gelatinous
Dataset brimming over with the information from the
ADODatasetCommand query. Now... we need to display this information!
be displayed through the use of a DataGrid. A DataGrid is an ASP.NET HTML control that renders a
into a nifty HTML table. DataGrids have tons of properties and customization features, but for this article we'll
simply look at a very simple use of a DataGrid.
An ASP.NET DataGrid control can be created with the following syntax:
To bind a
Dataset to a DataGrid, we first need to set the
DataSource property of the
DataGrid to our
Dataset; then, we simply call the
DataBind() method! Oftentimes we will
Dataview in the
DataSource property of the DataGrid control.
For our example below, we will use the
DataView of the
Dataset. (Egad, that's wordy!)
There are a couple of things to note in the above code. First, recall that
disconnected representations of data. Hence, we can close our
before using our
Dataset object, as I showed above. Second, note that we specified to use the
DefaultView for the DataGrid display by specifying
The output of the above script can be seen below. With old-school ASP, to produce the following output, we'd
simply loop through a Recordset object, creating the table as we proceed. The steps are a bit different using ASP.NET
|Comments from Scott Guthrie|
Scott Guthrie, one of the ASP.NET Developers, shares the following comments:|
"The following line of code required today (and in beta1):
will go away in beta2. Instead, it will just be:
This will eliminate the whole need to understand
Also, "For straight forward connected data access, you'll be able to use the
Well, that about wraps up data access in ASP.NET using ADO+. Hopefully you've learned something new! (Chances are you've learned a lot of new things!) All these new changes do seem a bit overwhelming, but hang in there! The best thing to do is roll your sleeves up and get playing around with ASP.NET code. As always, for the latest ASP.NET information, be sure to check out the ASP.NET Article Index!