Can anyone tell the function to sort the columns of a gridview in c# asp.net.
The databound to gridview is from datacontext created using linq. I wanted to click th
When I do that Alone it gives an error "The GridView 'GridView1' fired event Sorting which wasn't handled.
I've had that happen before... I've just created a throwaway handler, and then everything seemed to start working after that. Not the prettiest solution, but it worked for me.
That said, I didn't see any reference to a data source in your GridView code. You'll need something like this:
<asp:LinqDataSource ID="dsMyDataSource" runat="server"
DataContextTypeName="MyDataContext"
TableName="MyTable"
AllowSort="true" />
And then in your GridView:
<asp:GridView ID="gvMyGridView" runat="server" DataSourceID="dsMyDataSource" ... />