I'm trying to figure out how to sort a GridView
with multiple columns (String
, DateTime
, Decimal
, etc. data-types) which is bound to a generic list of custom objects.
MyObject.vb:
Public Property Id
Public Property Name
Public Property Date
Public Property Amount
MyObjects.aspx.vb:
gridView.DataSource = GetMyObjects()
gridView.DataBind()
Note: GetMyObjects()
returns a List
of MyObject
Basically, I need to be able to click on the column headers of the grid to sort and reverse sort, and also be able to store the sort direction in ViewState
so the direction persists each time I click on a column header.
It seems like I probably need MyObject
to implement IComparable
, but I'm not sure quite how to put it all together.
Can anyone suggest a good tutorial for this, or point me in the right direction?