Hi all,
i am using gridview control to display records. i am using System.Collections.Generic List<> as datasource. I want to perform sort operation in gridview. Please help me
Hi all,
i am using gridview control to display records. i am using System.Collections.Generic List<> as datasource. I want to perform sort operation in gridview. Please help me
Programmatically,
You may need to sort the List<>
before bind to gridview.
Or you may need to cast the gridview.DataSource
to List<>
explicitly and sort it.
If you want to sort the gridview on your GUI, then you need to set the gridview.AllowSorting
property to true
, then you should be able to sort.
Setting AllowSorting property to true should be enough. Are you looking for custom sort?
If you bind the data to a BindingSource, then bind the BindingSource to the grid, you should see it update properly when you sort, I believe.
Hi Geetha,
Try this tutorial -
Sorting GridView Using IComparer
In summary you can use the IComparable interface to define a custom sorting depending on what column heading you click.
Hope this helps.
Josh