You have to get its innerList... and .Sort in the inner list.
You also have to create a custom IComparer.
Here is a sample to get you started:
This assumes you have a
MyObjectToCompare object (which you will change to whatever a single object
of your collection is)
and
MyObjectToCompare.Age
MyObjectToCompare.Name
you'll replace with the properties you want to sort on.
using System;
using System.Collections;
namespace MyApp
{
internal sealed class MyFirstComparer : IComparer
{
private MyColumns m_sortValue = MyColumns.None ;
public enum MyColumns
{
None = 0 , Age = 1 , Name = 2
}
public MyFirstComparer(MyColumns sortValue)
{
m_sortValue = sortValue;
}
public int Compare(object x,object y)
{
switch(m_sortValue)
{
case MyColumns.None :
return 0;
case MyColumns.Name :
return ((MyObjectToCompare)x).Name
..CompareTo(((MyObjectToCompare )y).Name );
//break;
case MyColumns.Age :
return
(MyObjectToCompare)x).Age.CompareTo(((MyObjectToCo mpare )y).Age );
default:
return ((MyObjectToCompare)x).Name
..CompareTo(((MyObjectToCompare )y).Name );
// break;
}
}
}
}
"Bill44077" <Bi*******@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
Hi,
I have a gridview that I am displaying from an Eventlog. Is there any way
to sort this with the newest entries at the top rather than the way it is
delivered from the collection? I don't want to enable sorting to let the
user sort. Here is my code to bind:
System.Diagnostics.EventLog log = new
System.Diagnostics.EventLog("MyEventLog");
System.Diagnostics.EventLogEntryCollection entries =
log.Entries; BZPEventLog.DataSource = entries;
BZPEventLog.DataBind();
thanks in advance!
Bill