Hey, 

  This scenario perfectly works fine for me here. Find the attached
sample code. it works as expected. I use mono 1.1.7

  Let me know whether this works for you too. If not , I suggest to
upgrade ;-). If you have any other specific situation, please post a
simple code so that I can look into it.

suresh.

On Thu, 2005-04-14 at 16:12 -0700, Joe Audette wrote:
> Hi,
> 
> In my new RSS Feed Aggregator for mojoportal, I have a
> DataView named entries that I sort using:
> entries.Sort = "PubDate DESC";
> 
> On Windows it sorts by date desc as expected, but
> under mono 1.1.5 from svn on Suse 9.2 it sorts
> descending on date but keeps things grouped together
> by author so newer dated posts are not always on top.
> The feed with the newest post shows first but then all
> of its posts are shown next in date descending order
> no matter if the other feeds have posts that are
> newer, then the feed with the next newest post and so
> on.
> 
> I wonder if it has anything to do with the sequence of
> columns in the DataTable underlying the DataView. In
> my DataTable the PubDate field is the last column. I
> may try some more experimentation and see if I can
> find a workaround but I believe this is a bug and
> thought I should mention it.
> 
> Thanks,
> 
> Joe
> 
> joe_audette [at] yahoo dotcom
> http://www.joeaudette.com
> http://www.mojoportal.com
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
using System;
using System.Data;

class  MainClass
{
        public static void Main (string [] args)
        {

                DataTable dt = new DataTable ("test");
                dt.Columns.Add ("author", typeof (string));
                dt.Columns.Add ("id", typeof (int));
                dt.Columns.Add ("pubdate", typeof (DateTime));

                dt.Rows.Add (new object [] {"suresh", 5, new DateTime (2005,3,3)}) ;
                dt.Rows.Add (new object [] {"suresh", 10, new DateTime (2005,3,6)}) ;
                dt.Rows.Add (new object [] {"ramesh", 6, new DateTime (2005,3,2)}) ;
                dt.Rows.Add (new object [] {"ramesh",12, new DateTime (2005,1,2)}) ;
                dt.Rows.Add (new object [] {"kamesh", 3, new DateTime (2005,3,5)}) ;
                dt.Rows.Add (new object [] {"raju", 2, new DateTime (2005,2,5)}) ;

                Console.WriteLine ("DataTable : ");
                Print (dt);

                DataView dv = new DataView (dt, "author like '%sh'", "pubdate", DataViewRowState.CurrentRows);
                Console.WriteLine ("\nfiltered sorted view :");
                Print (dv);

                dv.Sort = "pubdate desc";
                Console.WriteLine ("\nsorting dec:");
                Print (dv);

        }

        public static void Print (DataTable dt)
        {
                for (int i = 0 ; i < dt.Columns.Count ; i++) {
                        Console.Write ("{0,20}", dt.Columns [i].ColumnName);
                }

                Console.WriteLine ();
                
                foreach (DataRow r in dt.Rows) {
                        for (int i =0 ; i < dt.Columns.Count; i++)
                                Console.Write ("{0,20}", r [i].ToString ());
                        Console.WriteLine ();
                }
                
        }


        public static void Print (DataView dv)
        {
                for (int i = 0 ; i < dv.Table.Columns.Count ; i++) {
                        Console.Write ("{0,20}", dv.Table.Columns [i].ColumnName);
                }

                Console.WriteLine ();
                
                foreach (DataRowView r in dv) {
                        for (int i =0 ; i < dv.Table.Columns.Count; i++)
                                Console.Write ("{0,20}", r [i].ToString ());
                        Console.WriteLine ();
                }
                
        }

        
}



Reply via email to