This walkthrough shows you how to bind a WebValueList to different DataSource control.
During this walkthrough, you will learn how to do the following:
- Use AccessDataSet
- Create DataSet.
- Use AccessDataSet SmartTag.
- Use WebGrid's SmartTag to bind to AccessDataSource.
- Use WebGrid.NET designer to bind a WebValueList.
Prerequisites
In order to complete this walkthrough, you will need the following:
- Access to the Microsoft Access Northwind database.
- Visual Studio 2005 Application.
Step-By-Step Instructions
- Launch Visual Studio.NET 2005.
- Click on File menu, then select New and click Project.
- Select Visual C# Project in Project Types.
- Select ASP.NET Web Application in the Template box.
- Specify the Project's Location and click OK.
- Drag WebGrid instance into WebForm.
- Drag two AccessDataSource controls into WebForm.
- In Solution Explorer, right click on the project then click "Add New Item...".
- Add a DataSet and name it NorthWind to the project.
- Add Order_Details and Products table to the dataset.
- Open first AccessDataSource SmartTag and bind to Order_Details table.
- Open second AccessDataSource SmartTag and bind to Products table.
- Open WebGrid's SmartTag and set the DataSource to AccessDataSource1 then click OK to Retrieve WebGrid's structure.
- Open WebGrid.NET Designer - Advanced tab - RootTable - Columns. Search for ProductID.
- In ValueList Expandable panel, set the following properties:
Property Value DataMember DefaultView DataSourceID AccesDataSource2 DataTextField ProductName DataValueField ProductID
- Compile and run the WebForm. The WebGrid will look like following: