Reputation: 30636
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.
Upvotes: 1
Views: 2680
Reputation: 146499
if summaryColumn is the name of the coulmn in the dataview that you want to sort on, put it into double quotes:
DataTable dt = f.Execute().Tables[0];
DataView dv = dt.DefaultView;
dv.Sort = "summaryColumn";
rptInner.DataSource = dv;
rptInner.DataBind();
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...
Upvotes: 4
Reputation: 1653
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).
Upvotes: 0