我是用object绑定数据源 listview采用自动分页,可每页只显示10条数据,怎样能让数据显示更多啊

解决方案 »

  1.   

    DataPager分页的使用,其中PageSize获取或设置为每个数据页显示的记录数。<asp:DataPager ID="dpArticle" runat="server" PagedControlID="lsv_article" PageSize="8"
            CurrentPageButtonClass="cpb" CssClass="paginator">
            <Fields>
                <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowNextPageButton="false" />
                <asp:NumericPagerField ButtonCount="10" />
                <asp:NextPreviousPagerField ShowPreviousPageButton="false" ShowNextPageButton="true"
                    ShowLastPageButton="true" />
            </Fields>
        </asp:DataPager>
      

  2.   

    <asp:ListView ID="ListView1" runat="server">
                <LayoutTemplate>
                    <table width="100%" cellspacing="1"  id="itemPlaceholderContainer" runat="server">
                        <tr>
                            <td width="10%">
                                编号
                            </td>
                            <td>
                                名称
                            </td>
                        </tr>
                        <tr ID="itemPlaceholder" runat="server">
                        </tr>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr >
                        <td>
                            <%# Eval("ID")%>
                        </td>
                        <td>
                            <%# Eval("Name")%>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:ListView>
            <webdiyer:AspNetPager ID="Pager" runat="server" AlwaysShow="True" CustomInfoHTML=""
                CustomInfoSectionWidth="40%" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"
                OnPageChanged="Pager_PageChanged" PageIndexBoxType="DropDownList" PageSize="10"
                PrevPageText="上一页" ShowCustomInfoSection="Left" ShowPageIndexBox="Always" SubmitButtonText="Go"
                TextAfterPageIndexBox="" TextBeforePageIndexBox="" UrlPaging="true">
            </webdiyer:AspNetPager>public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    BindInfo();
                }
            }        private void BindInfo()
            {
                Pager.CurrentPageIndex =Convert.ToInt32(Request.QueryString["page"]==null?"1":Request.QueryString["page"].Trim());            int pageSize = Pager.PageSize;
                int pageIndex = Pager.CurrentPageIndex;            List<User> list = new List<User>();
                for (int i = 0; i < 30; i++)
                { 
                    list.Add(new User(i,"oec2003"));
                }
                Pager.RecordCount = list.Count;
                ListView1.DataSource = list.Skip((pageIndex - 1) * pageSize).Take(pageSize);
                ListView1.DataBind();
            }        protected void Pager_PageChanged(object sender, EventArgs e)
            {
                BindInfo();
            }
        }    public class User
        {
            public User(int id, string name)
            {
                ID = id;
                Name = name;
            }
            public int ID { get; set; }
            public string Name { get; set; }
        }
    分页控件设置pageSize 就行了