将GridView绑定到DataTable [英] Sort GridView Bound to DataTable

查看:466
本文介绍了将GridView绑定到DataTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储库,其中包含我正在处理的这个项目的所有LINQ查询。我能够将LINQ结果转换为DataTable,并将其绑定到gridview以显示数据。现在我需要使gridview可排序。我设置了 AllowSorting =true,并且我在代码行中的例程中处理了OnSort事件。该程序使其进入排序例程很好。



手动排序我唯一的选项,还是在OnSort处理程序中更简单的排序gridview? >

解决方案

我最后使用这个来自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.

这篇关于将GridView绑定到DataTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆