The following topics explain how to perform data operations like sorting, filtering, paging, grouping, and column moving to your grid when data is bounded dynamically.
Sorting
To implement sorting, you need to handle the Sorting and Sorted events. Use the following code to rebind the grid in the Sorted event:
To write the code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Protected Sub C1GridView1_Sorting(sender As Object, e As C1.Web.Wijmo.Controls.C1GridView.C1GridViewSortEventArgs) Handles C1GridView1.Sorting End Sub 'Handles Sorting Protected Sub C1GridView1_Sorted(sender As Object, e As EventArgs) Handles C1GridView1.Sorted C1GridView1.DataSource = BindGrid() C1GridView1.DataBind() End Sub |
To write the code in C#
C# |
Copy Code
|
---|---|
protected void C1GridView1_Sorting(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewSortEventArgs e) { } //Handles Sorting protected void C1GridView1_Sorted(object sender, EventArgs e) { C1GridView1.DataSource = BindGrid(); C1GridView1.DataBind(); } |
Filtering
To implement filtering, you need to handle the Filtering and Filtered events. Use the following code to rebind the grid in the Filtered event:
To write the code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Protected Sub C1GridView1_Filtering(sender As Object, e As C1.Web.Wijmo.Controls.C1GridView.C1GridViewFilterEventArgs) End Sub 'Handles Filtering Protected Sub C1GridView1_Filtered(sender As Object, e As EventArgs) Handles C1GridView1.Filtered C1GridView1.DataSource = BindGrid() C1GridView1.DataBind() End Sub |
To write the code in C#
C# |
Copy Code
|
---|---|
protected void C1GridView1_Filtering(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewFilterEventArgs e) { } //Handles Filtering protected void C1GridView1_Filtered(object sender, EventArgs e) { C1GridView1.DataSource = BindGrid(); C1GridView1.DataBind(); } |
Paging
To implement paging, you need to handle the Paging event. Use the following code to rebind the grid in the grid after you set the NewPageIndex as the PageIndex of C1GridView:
To write the code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
'Handles Paging Protected Sub C1GridView1_PageIndexChanging(sender As Object, e As C1.Web.Wijmo.Controls.C1GridView.C1GridViewPageEventArgs) Handles C1GridView1.PageIndexChanging C1GridView1.PageIndex = e.NewPageIndex C1GridView1.DataSource = BindGrid() C1GridView1.DataBind() End Sub |
To write the code in C#
C# |
Copy Code
|
---|---|
//Handles Paging protected void C1GridView1_PageIndexChanging(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewPageEventArgs e) { C1GridView1.PageIndex = e.NewPageIndex; C1GridView1.DataSource = BindGrid(); C1GridView1.DataBind(); } |
Grouping
To implement grouping, you need to handle the ColumnGrouped and ColumnUngrouped events.
Use the following code to rebind the grid in the ColumnGrouped event while providing HeaderText of the dragged column as the parameter:
To write the code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
'Handles Column UnGrouping Protected Sub C1GridView1_ColumnUngrouped(sender As Object, e As C1.Web.Wijmo.Controls.C1GridView.C1GridViewColumnUngroupedEventArgs) Handles C1GridView1.ColumnUngrouped End Sub 'Handles Column Grouping Protected Sub C1GridView1_ColumnGrouped(sender As Object, e As C1.Web.Wijmo.Controls.C1GridView.C1GridViewColumnGroupedEventArgs) Handles C1GridView1.ColumnGrouped C1GridView1.DataSource = BindGrid(e.Drag.HeaderText) C1GridView1.DataBind() End Sub |
To write the code in C#
C# |
Copy Code
|
---|---|
//Handles Column UnGrouping protected void C1GridView1_ColumnUngrouped(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewColumnUngroupedEventArgs e) { } //Handles Column Grouping protected void C1GridView1_ColumnGrouped(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewColumnGroupedEventArgs e) { C1GridView1.DataSource = BindGrid(e.Drag.HeaderText); C1GridView1.DataBind(); } |
Column Moving
To implement column moving, you need to handle the ColumnMoving and ColumnMoved events. Use the following code to rebind the grid in the ColumnMoved event:
To write the code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Protected Sub C1GridView1_ColumnMoving(sender As Object, e As C1.Web.Wijmo.Controls.C1GridView.C1GridViewColumnMoveEventArgs) Handles C1GridView1.ColumnMoving End Sub 'Handles ColumnMoving Protected Sub C1GridView1_ColumnMoved(sender As Object, e As EventArgs) Handles C1GridView1.ColumnMoved C1GridView1.DataSource = BindGrid() C1GridView1.DataBind() End Sub |
To write the code in C#
C# |
Copy Code
|
---|---|
protected void C1GridView1_ColumnMoving(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewColumnMoveEventArgs e) { } //Handles ColumnMoving protected void C1GridView1_ColumnMoved(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewColumnMovedEventArgs e) { C1GridView1.DataSource = BindGrid(); C1GridView1.DataBind(); } |