To enable features and functionality in WebDataGrid™ use the Behaviors collection. You can add behaviors to this collection in order to enable WebDataGrid’s various features, such as sorting and paging. Behaviors are automatically enabled as you add them to the collection. You can disable a behavior without removing it from the collection by setting its Enabled property to False. Any added behaviors are displayed and accessible through the Microsoft® Visual Studio™ property window under WebDataGrid’s behaviors collection.
Properties and client-side events that apply to a behavior can be adjusted when adding the behavior or in the property window after adding the behavior.
You will learn how to enable sorting for WebDataGrid using the Sorting Behavior.
Bind WebDataGrid to a SqlDataSource component retrieving data from the Customers table. For more information on doing this, see Binding WebDataGrid to a SQL Data Source.
In the property window, locate the Behaviors property and click the ellipsis (…) button to launch the Behaviors Editor Dialog.
Check the CheckBox next to Sorting from the list of behaviors on the left to enable the behavior.
Leave SortingMode as Single in the properties.
Click Ok to close the dialog window.
Expand the Behaviors collection in the properties grid to see that Sorting has been added.
Run the application. You can sort one column at a time in WebDataGrid.