简体   繁体   中英

How to sort a gridview - Icollection?

I Have a gridview bound on a Icollection. I need to sort this gridview so I tried to :

  • set the AllowSorting attribute on true
  • the SortExpression of my BoundFields

But when I click on the headers of my grid I got and exception saying the event is not handled... So I added an eventHandler method but I don't know what to put in this method. I tried this but of course it didn't work (recursive)

protected void MyGrid_OnSorting(object sender, GridViewEventArgs e)
{ this.mygrid.Sort(e.SortExpression, e.SortDirection); }

I can't use linq (Frmwk 2.0) and it's not my application so I can't change too many things. Is there another kind of collection or list which can be sorted with a SortExpression and SortDirection and bound a griview ?

Thanks.

你加了吗

OnSorting="MyGrid_OnSorting"

Ok I had to convert the Icollection to a Datatable. If it can help...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM