使用数据视图对数据集进行排序
此代码正确获取数据并显示它;然而,这种排序完全被忽视了。
DataTable dt = f.Execute().Tables[0];
dt.DefaultView.Sort = summaryColumn;
rptInner.DataSource = dt.DefaultView;
rptInner.DataBind();
我可以做些什么来强制视图自行排序吗?
(f.Execute() 返回位置为 0 的 at table 的数据集,summaryColumn 是表中列的名称,rptInner 是重复器控件)
edit
summaryColumn 是一个字符串变量,具有精确的值我想要排序的列的名称。我没有使用存储过程或任何东西,数据集是给我的,我负责对其进行排序。
This code correctly fetches data, and displays it; however, the sort is completely ignroed.
DataTable dt = f.Execute().Tables[0];
dt.DefaultView.Sort = summaryColumn;
rptInner.DataSource = dt.DefaultView;
rptInner.DataBind();
Is there something I can do to force the view to sort itself?
(f.Execute() returns a dataset with at table at position 0, summaryColumn is the name of a column in the table, rptInner is a repeater control)
edit
summaryColumn is a string variable that has the exact name of the column I want to sort on. I am not using sproc or anything, the DataSet is given to me and I'm responsible for sorting it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果summaryColumn是数据视图中要排序的列的名称,请将其放入双引号中:
如果它是保存列名称的字符串变量,请确保它的值是所需列的确切字符串名称排序...
if summaryColumn is the name of the coulmn in the dataview that you want to sort on, put it into double quotes:
If it's a string variable holding the name of the column, make sure it's value is the exact string name of the column you want to sort on...
我在服务器端排序,如果您使用执行调用中的存储过程,请在结果集上放置一个 Order By 语句(如果是 SQL)。
I sort on the server side, if you are using a stored proc from the execute call put an Order By statement on the result set (if it is SQL).