I have a pagedatacollection... Right now im sorting this collection by "date" and then by "division" with FilterPropertySort... the following way:
new FilterPropertySort("Date", FilterSortDirection.Descending).Filter(KPages); new FilterPropertySort("Division").Filter(KPages);
Somehow it seems like the later sorting is messing up the first sorting (in some cases)... The order by date is not fully maintained. I wonder if am doing this the wrong way maybe... How could/should I sort this collection in another way?
How about if you use OrderBy() and ThenBy() LINQ extension methods?
Okey... I've had a look at LINQ now and I feel a bit confused (I haven't used LINQ before). I tried the following
var alist = from p in DataFactory.Instance.GetChildren(aPage) orderby p.Property["Date"] select p;
rptList.DataSource = alist; rptList.DataBind();
I run into problems with the datasource at runtime (Err: At least one object must implement IComparable.). I'm using a repeater to display my list. If you have some "for dummies" example that I can learn from it would be great :) Have done a bit of searching on the subject and the links tend to lead me to places where I don't belong atm ;)
This error comes from the orderby statement and the p.Property["Date"]. If you trying to sort by publish date use that instead:
Your right! The thing is, I'm not trying to sort it by publishdate... I wanna sort it by a property (Date) that describes when something is happening (DateTime). It should be possible right?
Yes, just cast it to DateTime.
Hmm... I tried that earlier but get "Cannot convert type EPiServer.CorePropertyData" to "System.DateTime". Thank you for your replies :) Any ideas?
YES! Awesome :) Many thanks Frederik... Good to know for future use. Hope you have a real nice day now :)