sort columns of gridview in asp.net c#

前端 未结 7 416
别那么骄傲
别那么骄傲 2020-12-17 00:43

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

相关标签:
7条回答
  • 2020-12-17 01:28

    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" ... />
    
    0 讨论(0)
提交回复
热议问题