Datasheet
You can see just the required columns in Figure 8-13.
10. Press Next.
11. From the Name Method window, change the name textbox to GetProductsDataSet. Make sure
the radio button at the bottom is set to
DataSet and press Finish. We'll look at the DataReader
later in the chapter.
12. Once the code has been added, you want a way to display it. You can do this by switching to
Design view and dragging a DataGrid onto the page.
13. Switch to Code view and add the following code, after the GetProductsDataSet function:
void Page_Load(Object sender, EventArgs e)
{
DataGrid1.DataSource = GetProductsDataSet();
DataGrid1.DataBind();
}
14. Save the page and run it – you should see Figure 8-14:
Figure 8-14
You can see how we now only have two columns and from two different tables. Let's see how this
works.
How It Works
The key to this is the wizard that allows you to build up an SQL statement. This is great if you are a
newcomer to SQL as you don't have to understand how the SQL language works. Perhaps the most
important part of this wizard is the
WHERE Clause Builder shown in Figure 8-11.
265
Reading from Databases
57084_08.qxp 30/01/2004 8:03 PM Page 265