开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜