Datasheet
DataGrid1.DataSource = GetProducts(lstCategory.SelectedValue)
DataGrid1.DataBind()
End Sub
7. Underneath that procedure, add the following code:
Sub Page_Load(Sender As Object, E As EventArgs)
If Not Page.IsPostback Then
lstCategory.DataSource = GetCategories()
lstCategory.DataValueField = "CategoryID"
lstCategory.DataTextField = "CategoryName"
lstCategory.DataBind()
End If
End Sub
8. Underneath that, drag a SELECT Data Method wizard from the toolbox onto the page. Pick the
current database connection and select the 
CategoryID and CategoryName columns from the
Categories table. Call the procedure GetCategories and have it return a DataSet.
9. Underneath that, drag another SELECT Data Method wizard onto the page. Pick the current
database connection, and select 
ProductName, QuantityPerUnit, UnitPrice, and
UnitsInStock from the Products table. 
10. Click the WHERE button and pick the CategoryID from the Products table making it Filter on
@CategoryID, as shown in Figure 8-21:
Figure 8-21
11. Click OK and Next to get to the Name Method screen.
12. Call the procedure GetProducts and have it return a DataSet. Press Finish to insert the code.
279
Reading From Databases
57076_Ch 8 SAN.qxd 01/12/2003 6:43 PM Page 279










