Engineer Forum

Computer Science => Programming Languages => .NET => : hcengiz October 11, 2007, 07:23:27 AM

: DataGrid Paging and Sorting Implementation
: hcengiz October 11, 2007, 07:23:27 AM
Unless you use ASP.NET's auto designer mode and auto features, you have to implement sorting and paging methods for the Datagrid in C# or VB.NET codes.

1) Declare the page index changed event and its handler in InitializeComponent() method of the C# code.

2) Implement the method which will set the index to the new page index.
 private void DataGrid1_PageIndexChanged(object source,   DataGridPageChangedEventArgs e) {

Do the same for sorting.

If the database query returns huge number or records, you may wanna consider Caching the recordset. Otherwise, each PageIndexChanged event will cause hitting the database again and again which results in a performance decrease.
Use the method Cache.Insert(dataset) to do this.

source: (