Version

Adding a Behavior at Design Time

Before You Begin

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.

What You Will Accomplish

You will learn how to enable sorting for WebDataGrid using the Sorting Behavior.

Follow these Steps

  1. 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.

  2. In the property window, locate the Behaviors property and click the ellipsis (…​) button to launch the Behaviors Editor Dialog.

  3. Check the CheckBox next to Sorting from the list of behaviors on the left to enable the behavior.

  4. Leave SortingMode as Single in the properties.

images\WebDataGrid Using Behaviors 01.png
  1. Click Ok to close the dialog window.

  2. Expand the Behaviors collection in the properties grid to see that Sorting has been added.

images\WebDataGrid Using Behaviors 02.png
  1. Run the application. You can sort one column at a time in WebDataGrid.

images\WebDataGrid Sort Columns in Code 01.png