C# ADO.NET实体框架不允许gridview单击排序列?
我使用的是ADO.NET实体框架数据模型。我通过ADO.NET实体框架将数据从SQL发送到GridViewC# ADO.NET实体框架不允许gridview单击排序列?,c#,.net,asp.net,entity-framework,C#,.net,Asp.net,Entity Framework,我使用的是ADO.NET实体框架数据模型。我通过ADO.NET实体框架将数据从SQL发送到GridView 但是,如果我使用EF,如何对gridview的列进行排序?请阅读本文以对ASP.NET gridview对象进行排序 ... :) 阅读此内容对ASP.NET GridView对象进行排序 ... :) 您使用的是EntityDataSource?您是否在GridView上启用了AllowSorting和AllowPaging属性 <asp:GridView ID="Grid
但是,如果我使用EF,如何对gridview的列进行排序?请阅读本文以对ASP.NET gridview对象进行排序
... :) 阅读此内容对ASP.NET GridView对象进行排序
... :) 您使用的是
EntityDataSource
?您是否在GridView上启用了AllowSorting
和AllowPaging
属性
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="True"
DataSourceID="EntityDataSource1">
</asp:GridView>
<asp:EntityDataSource ID="EntityDataSource1" runat="server"
ConnectionString="......"
EntitySetName="......."
Select=".........." OrderBy="......">
</asp:EntityDataSource>
Marc您是否使用
EntityDataSource
?您是否在GridView上启用了AllowSorting
和AllowPaging
属性
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="True"
DataSourceID="EntityDataSource1">
</asp:GridView>
<asp:EntityDataSource ID="EntityDataSource1" runat="server"
ConnectionString="......"
EntitySetName="......."
Select=".........." OrderBy="......">
</asp:EntityDataSource>
Marc我不使用EntityDataSource,为什么我需要它。我想把它做成C代码。用它!这是免费获得排序和分页的方法。如何通过单击列对gridview列进行排序?我不使用belowvoid LoadProducts(){ABCBusinessFrameWork.\u SQLAccessLayer client=new ABCBusinessFrameWork.LoadData();Session[“TaskTable”]=client.GetAllData(“sp_GetAllProducts”,CommandType.StoredProcedure);gvProducts.DataSource=Session[“TaskTable”];gvProducts.DataBind()}受保护的无效GVU排序(对象发送方,GridViewSortEventArgs e){//从会话对象检索表。DataTable dt=session[“TaskTable”]作为DataTable;我不使用EntityDataSource为什么我需要它。我想让它成为C代码。使用它!这是免费获得排序和分页的方法。如何通过单击列对gridview列进行排序?我不使用belowvoid LoadProducts(){ABCBusinessFrameWork.\u SQLAccessLayer client=new ABCBusinessFrameWork.LoadData();会话[“TaskTable”]=client.GetAllData(“sp_GetAllProducts”,CommandType.StoredProcedure);gvProducts.DataSource=Session[“TaskTable”];gvProducts.DataBind();}受保护的无效gvProducts_排序(对象发送方,GridViewSortEventArgs e){//从会话对象检索表。DataTable dt=Session[“TaskTable”“]作为数据表;