To specify a custom SELECT statement perform the following steps:
1. Click on the ">" icon on the SqlDataSource1 control, then click on the "Configure Data Source"
2. Click the "Next" button until you reach the "Configure the Select Statement" screen, select the "Specify a custom SQL statement or stored procedure" radio button. Then click the "Next" button
3. On the "Define Custom Statements or Stored Procedures" screen select the "SELECT" tab, and then type in the following SELECT statement to get the CategoryName field in the Categories table, and the CompanyName field in the Suppliers table. Then click on the "Next" button.
SELECT ProductName,
Categories.CategoryName AS Category,
Suppliers.CompanyName AS Supplier,
QuantityPerUnit,
UnitPrice,
UnitsInStock,
UnitsOnOrder,
ReorderLevel,
Discontinued
FROM Products,Categories,Suppliers
WHERE Products.CategoryID = Categories.CategoryID
AND Products.SupplierID = Suppliers.SupplierID
5. Now the GridView is populated with the columns specified in the custom SELECT statement
No comments:
Post a Comment