可以使用动态 SELECT 语句字符串填充 DevExpress XtraGrid
可以使用动态 SELECT 语句字符串填充 DevExpress XtraGrid 吗?
IE 从员工中选择*
或
SELECT * FROM Dependents
当前为了填充我们的 XtraGrid,我们使用创建实体的 ORM。要做到这一点需要很多步骤和时间。促使我问这个问题的原因是我们进行了大量的客户采购,获得了数百个文件。我不想为所有这些创建实体,然后必须为每个实体创建一个 XtraGrid。理想情况下,如果我可以向它提供一个 SELECT 语句,并且 XtraGrid 可以呈现它,那么我可以使用 XtraGrid 非常好的数据最小化功能(过滤器、分组依据等)。
如果您有任何其他想法或建议,请随时发布。
修订:
根据下面的 Brendon 响应创建一个返回 DataTable 的静态方法。
这是实际执行此操作的页面的链接。 http://msmvps.com/blogs/deborahk/archive/2009/07/07/dal-retrieve-a-datatable-using-a-sql-statement.aspx
Can a DevExpress XtraGrid be filled using a a Dynamic SELECT statement string?
i.e.
SELECT * FROM Employee
or
SELECT * FROM Dependents
To fill our XtraGrids currently, we use a ORM that creates entities. To do this it takes a lot of steps and time. What is driving me to ask this question is we do a lot of client aquistions where we get hundreds of files. I do not want to create entities for all of these then have to create an XtraGrid for each entity. Ideally if I can just feed it a SELECT statement and the XtraGrid could render it then I could use the XtraGrid very nice data minipulation features (Filter, Group By, etc).
If you have any other ideas or suggestions please do not hesitate to post them.
Revised:
Per Brendon's responce below to create a static method that returns a DataTable.
Here is a link to a page that actually does that. http://msmvps.com/blogs/deborahk/archive/2009/07/07/dal-retrieve-a-datatable-using-a-sql-statement.aspx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
XtraGrid 没有任何内置机制来从 SQL 语句创建数据源。对我来说,完成此任务的最简单方法是简单地创建一个静态方法,该方法从 SQL 语句构建并返回 DataTable/DataSet。然后我可以将 XtraGrid 的数据源设置为此方法的结果。
The XtraGrid doesn't have any built-in mechanisms to create a data source from a SQL statement. For me, the easiest way to accomplish this is to simply create a static method that builds and returns a DataTable/DataSet from a SQL statement. I can then set the XtraGrid's data source to the results of this method.