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.
Prerequisites
In order to complete this walkthrough, you will need the following:
- Visual Studio 2005/2008/2010 Application.
Step-By-Step Instructions
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 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 a WebGrid instance into WebForm.
- Drag two SqlDataSource controls into WebForm.
- Right click to the SqlDatasource1 and select Configure Datasource, then choose SqlSampleConnection.
- Select statement "SELECT * FROM [Employees]".
- Right click to the SqlDatasource2 and select Configure Datasource, then choose SqlSampleConnection.
- Select statement "SELECT [RoleId], [RoleName] FROM [Roles]".
- Open WebGrid.NET 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:
Property Value DataSourceID SqlDataSource2 DataTextField RoleName DataValueField RoleId EnableMultipleValues True
- Compile and run the WebForm. The WebGrid will look like following.
Tasks
Walkthrough: Binding a WebValueList to a table defined in ISDataSourceControl
Walkthrough: Binding a WebValueList to different DataSource control
References
WebValueList Class
AllowEdit Property
EnableMultipleValues Property
DataSourceID Property
DataTextField Property
DataValueField Property
Other Resources
Walkthrough Topics
How-to Topics