ComponentOne GridView for ASP.NET WebForms
Task-Based Help / Updating the Grid with AJAX / Sorting Columns
In This Topic
    Sorting Columns
    In This Topic

    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, expand the CallbackSettings node, click the drop-down arrow next to the Action 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:

    To write the code in Visual Basic:

    Visual Basic
    Copy Code
    C1GridView1.AllowSorting = True
     C1GridView1.CallbackOptions = CallbackOptions.Sorting

    To write the code in C#:

    C#
    Copy Code
    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.

    See Also