Gridview and list <>

I am using gridview to display posts. I am using System.Collections.Generic List <> as data source. I want to perform a sort operation on a gridview. Please help me

+2


source share


4 answers


Try this tutorial -

Sorting a GridView with IComparer

In conclusion, you can use the IComparable interface to define a custom sort based on which header column you click.



Hope it helps.

Josh

+1


source


Setting the AllowSorting property to true should be sufficient. Are you looking for a custom look?



+1


source


Programmatically,

You may need to sort List<>

before binding to the gridview.

Or, you may need to explicitly point gridview.DataSource

to List<>

and sort it.

If you want to sort the gridview in your GUI, you need to set a gridview.AllowSorting

property true

, then you should be able to sort.

0


source


If you bind data to a BindingSource and then bind the BindingSource to a grid, you should see that it updates correctly when you sort, I believe.

0


source







All Articles