views:

290

answers:

2

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.

+2  A: 

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...

Charles Bretana
I should've been more clear, summaryColumn is the name of a String object that contains the name of the column I'd like to sort on. I verified that the name of the column I am using is the same as what is in the Columns collection. Even the case is the same. Any thoughts?
Nate Bross
Try changing the order of the statements, as in my edited code...
Charles Bretana
A: 

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).

Decker97
Sadly its not SQL, I get the dataset from a class library, I have no abbility to change it.
Nate Bross