Author Topic: DataGrid Paging and Sorting Implementation  (Read 2828 times)

hcengiz

  • Administrator
  • Newbie
  • *****
  • Posts: 9
    • View Profile
DataGrid Paging and Sorting Implementation
« on: 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: http://csharpeasy.blogspot.com

Engineer Forum

DataGrid Paging and Sorting Implementation
« on: October 11, 2007, 07:23:27 AM »