This is some sample code which shows you how to fully implement a data grid with sorting, paging and searching features. It was taken into consideration while writing the code to separate the business-related code from the core implementation as far as possible without adding too much complexity to the whole solution. You can deal with the code as a base which you can modify to be adapted to your needs.
For any further details, please check this article.