This walkthrough shows you how to configure the WebValueList of a WebGridColumn
to translate multiple values data.
During this walkthrough, you will learn:
- Use SqlDatasource to bind the grid.
- Use WebValueList.
- To translate multiple values data using improved WebValueList feature.
In order to complete this walkthrough, you will need the following:
- Visual Studio 2005/2008/2010 Application.
To configure the WebValueList of a WebGridColumn to translate multiple
values data
- Launch Visual Studio.NET 2008.
- Click on File menu, then select New and click
Web Site.
- Select ASP.NET Web Site in Template Box and set Location
to HTTP.
- Named the Web Site and click OK.
- Drag a WebGrid instance into WebForm.
- Drag two SqlDataSource controls into WebForm.
- Right click to the SqlDatasource1 and select Configure
Datasource, then choose SqlSampleConnection.
- Choose Employees from the dropdownlist table and check all (*) columns.
- Right click to the SqlDatasource2 and select Configure
Datasource, then choose SqlSampleConnection.
- Choose Roles from the dropdownlist table and check RoleId and RoleName columns.
- Open WebGrid's SmartTag. In Choose Data Source field, select SqlDataSource1 from the dropdownlist.
- Select Retrieve Structure and click OK afterwards.
- Open WebGrid Designer - RootTable - Columns. Add EmployeeID,
FirstName, LastName, JoinDate,
Roles columns.
- In LayoutSettings, set AllowEdit to Yes.
- In the Roles properties, expand ValueList and
set the following properties:
DataSourceID
|
SqlDataSource2
|
DataTextField
|
RoleName
|
DataValueField
|
RoleId
|
EnableMultipleValues
|
True
|
- Compile and run the WebForm. The WebGrid will look like following.