ComponentOne GridView for ASP.NET AJAX: GridView for ASP.NET AJAX Task-Based Help > Updating the Grid with AJAX > Sorting Columns

Sorting Columns

You can use AJAX to update the grid when the user sorts a column at run time. For example, you can update the grid with AJAX on column sort in the Designer, in Source view, and in code. For more information about sorting, see the Sorting topic.

In the Designer

To enable AJAX when sorting on a column, complete the following steps:

1.   Select the C1GridView control and click the Smart Tag to open the C1GridView Tasks menu.

2.   Select Property builder. The C1GridView Properties dialog box (the Property builder) appears.

3.   Click the General tab and select the Allow sorting check box in the Behavior section.

4.   Click OK to close the Property builder. If you run the program now, you will notice that the whole page refreshes when you sort a column.

5.   In the project, with the C1GridView control still selected, click the drop-down arrow next to the CallbackOptions property in the Properties window and check the Sorting check box.

In Source View

Switch to Source view and add AllowSorting="True" and CallbackOptions="Sorting" to the <cc1:C1GridView> tag, so it appears similar to the following:

<cc1:C1GridView ID="C1GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" VisualStylePath="~/C1WebControls/VisualStyles" AllowSorting="True" CallbackOptions="Sorting">

In Code

To enable AJAX when filtering a column, add the following code to the Page_Load event:

      Visual Basic

C1GridView1.AllowSorting = True

C1GridView1.CallbackOptions = CallbackOptions.Sorting

      C#

C1GridView1.AllowSorting = true;

C1GridView1.CallbackOptions = CallbackOptions.Sorting;

 What You've Accomplished

Now when you run the program and sort a column, you will notice that only the grid, and not the entire page, refreshes.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.