【问题标题】:Adding paging to ListView using model binding使用模型绑定向 ListView 添加分页
【发布时间】:2013-11-05 01:04:03
【问题描述】:

我正在使用 .NET 4.5 并希望将分页添加到使用模型绑定的 ListView。

我已经谷歌搜索并找到了答案:

http://dotnet.learningtree.com/2012/11/30/efficient-paging-with-model-binding-in-web-forms/

但是,由于代码 sn-ps 是作为图像完成的,作者说“当我添加一个新的 GetData() 方法时,它会在代码隐藏中创建一个带有 IQueryable 的存根......”我看不到那个已添加。

谁能指出我正确的方向?我要做的就是向我的 ListView 添加分页,该 ListView 以一种有效的方式绑定模型。

【问题讨论】:

    标签: c# asp.net linq listview entity-framework-5


    【解决方案1】:

    在您的内部<asp:ListView... 标签类型SelectMethod,您将获得一个方法存根生成器助手。如果您按 TAB,它将在您的代码中创建一个方法 ListViewId_GetData。全图:

    <asp:ListView SelectMethod="ListView1_GetData" ID="ListView1" runat="server">
    </asp:ListView>
    

    代码隐藏:

    public IQueryable ListView1_GetData()
    {
        return null;
    }
    

    【讨论】:

    • 那不解释int id、int currentRow、int pageSize参数从何而来。
    • 如果您使用的是 Visual Studio 2012,当您添加 SelectMethod 时,您会在代码后面看到自动添加的注释,说明一切。这里是 cmets:The return type can be changed to IEnumerable, however to support paging and sorting, the following parameters must be added: int maximumRows int startRowIndex out int totalRowCount
    猜你喜欢
    • 1970-01-01
    • 2017-06-24
    • 1970-01-01
    • 1970-01-01
    • 2018-05-13
    • 2017-05-31
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    相关资源
    最近更新 更多