gridview sorting
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.
精彩评论