开发者

How to sort a GridView with a ColumnHeader click when AutoGenerateColumns="true"

开发者 https://www.devze.com 2023-03-21 01:17 出处:网络
I have a gridview with AutoGenerateColumns=\"true\" (in general I don\'t know what the columns will be). Is there any easy way to sort the grid by clicking on a column header? The only solutions I hav

I have a gridview with AutoGenerateColumns="true" (in general I don't know what the columns will be). Is there any easy way to sort the grid by clicking on a column header? The only solutions I have found so far are for when AutoGenerateColumns="false"

Alternatively if I know one of the columns is going to be called StatusId is there a way to sort on this c开发者_StackOverflow中文版olumn only?

Edit: I am manually updating the gridview's HeaderRow to make them more user friendly, this seems to be knocking things out. Is there a way to get round this?


Did you try to Set AllowSorting="true" in the gridview ?

If that's not working for you then you can implement custom Sorting,

You can get custom sorting code from this thread: How to convert a GridView to DataTable and sort the DataTable?

0

精彩评论

暂无评论...
验证码 换一张
取 消