开发者

gridview sorting

开发者 https://www.devze.com 2023-02-07 02:40 出处:网络
I have a gridview that I load from a linq query. MyGridData is a the list that\'s returned from the linq query and that contains a variable called MyVariable. So, in the code behindI have:

I have a gridview that I load from a linq query.

MyGridData is a the list that's returned from the linq query and that contains a variable called MyVariable. So, in the code behind I have:

MyGrid.DataSource = MyGridData;
MyGrid.DataBind();

I then went to the aspx source and added AllowSorting = true and to the boundfield I want to enable sorting for, I added SortExpression = "MyVariable".

When the page renders, if I click on the header of the column to sort the grid, I get a yellow death screen with this message:

开发者_StackOverflow中文版The GridView 'MyGrid' fired event Sorting which wasn't handled

What am I doing wrong?

Thanks.


You have to implement the handler for the Sorting-Event in the Codebehind. Sort your datasource and bind your grid again.

0

精彩评论

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