This walkthrough shows you how to configure automatic column sorting for a column using WebValueList.
During this walkthrough, you will learn:
- Use ISDatasource to bind the grid.
- Use WebValueList.
Prerequisites
In order to complete this walkthrough, you will need the following:
- Visual Studio 2005 Application.
Step-By-Step Instructions
To Configure Automatic Column Sorting for a Column using WebValueList
- 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 a WebGrid instance into WebForm.
- Drag an ISDataSource control into WebForm.
- Right click to the ISDatasource1 and select Configure Datasource. Choose ShemaType to DataSet and Schema Name to dsNorthWind_ReadOnly, then click Next.
- Add Categories, Products, and Suppliers tables. Click Finish.
- Open WebGrid.NET Designer - RootTable - Columns. Add ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, Discontinued columns.
- In the SupplierID properties, set GroupInterval property to Text.
- Expand ValueList and set the following properties:
Property Value DataMember Suppliers DataTextField CompanyName DataValueField SupplierID
- In the CategoryID properties, set GroupInterval property to Text.
- Expand ValueList and set the following properties:
Property Value DataMember Categories DataTextField CategoryName DataValueField CategoryID
- Go to WebGrid LayoutSettings, set AllowGrouping to Yes and AllowFiltering to Yes.
- Go to RootTable, set UseValueListForSorting property to Yes.
- Compile and run the WebForm. The WebGrid will look like following.