gridview sort

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • maz77

    gridview sort

    I'm working with VisualStudio and C#, and I'll try to explain the problem...
    I've built a custom class called "User.cs" that contains only Properties
    with set and get methods (ex: FirstName, LastName,...), and another
    custom class "UserCollection .cs" that is simply a list<User>.
    If I need to show a list of Users, simply I bind a gridview with a
    UserCollection and all works fine... until I try to make a sorting of
    the gridview...
    Is it possible to sort a gridview binded with custom class collection,
    or I've no choice but to use an ObjectDataSourc e?

    Thanks

    MAX
  • =?Utf-8?B?ZG90TmV0RGF2ZQ==?=

    #2
    RE: gridview sort

    You will have to do the sorting yourself using the IComparable Interface.
    Here is a link to some info on it:

    Defines a generalized type-specific comparison method that a value type or class implements to order or sort its instances.


    You could also use LINQ.

    David

    =============== =============== ========
    David McCarter [Microsoft MVP]

    David McCarter''''s .NET Coding Standards available at:



    "maz77" wrote:
    I'm working with VisualStudio and C#, and I'll try to explain the problem...
    I've built a custom class called "User.cs" that contains only Properties
    with set and get methods (ex: FirstName, LastName,...), and another
    custom class "UserCollection .cs" that is simply a list<User>.
    If I need to show a list of Users, simply I bind a gridview with a
    UserCollection and all works fine... until I try to make a sorting of
    the gridview...
    Is it possible to sort a gridview binded with custom class collection,
    or I've no choice but to use an ObjectDataSourc e?
    >
    Thanks
    >
    MAX
    >

    Comment

    Working...