且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将GridView绑定到DataTable

更新时间:2022-10-15 07:47:06

我最后使用这个来自MSDN的示例,并附加我自己的datatable,它是通过我的存储库中的LINQ Query获得的。


I have a repository that contains all of my LINQ queries for this project that I am working on. I am able to get the LINQ results to a DataTable and bind that to a gridview for displaying the data. Now I need to make the gridview sortable. I have set AllowSorting="true" and I have the OnSort event handled in a routine in the codebehind. The program makes it into the sorting routine just fine.

Is manual sort my only option or is there an easier way to sort the gridview in the OnSort handler?

I ended up solving this problem using this example from MSDN and attaching my own datatable, which was acquired through a LINQ Query in my repository.