Repeater 和分页的例子

来源:互联网 发布:js文件用加密吗 编辑:程序博客网 时间:2024/05/16 13:49

前后:

<table >

                    <tr class="gridtitle" align="center">
                        <th>
                            序号
                        </th>
                        <th>
                            业务单号
                        </th>
                        <th>
                            业务标题
                        </th>
                        <th>
                            客户姓名
                        </th>
                        <th>
                            浏览
                        </th>
                    </tr>
                    <asp:Repeater ID="rpResources" runat="server">
                        <ItemTemplate>
                            <tr class="tdbg" align="center">
                                <td>
                                    <input id="chk<%# Container.ItemIndex%>" type="checkbox" />
                                    <input id="TagID<%# Container.ItemIndex%>" type="hidden" value="<%# Eval("id")%>" />
                                    <%# Container.ItemIndex+1 %>
                                </td>
                                <td>
                                    <%# Eval("serSN")%>
                                </td>
                                <td>
                                    <%# Eval("serTitle")%>
                                </td>
                                <td>
                                    <%# Eval("fullName")%>
                                </td>
                                <td>
                                    <a onclick="viewbus(<%# Eval("id")%>)">
                                        <img title="浏览" src="/Resources/Images/view.gif" border="0" /></a>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                    <input name="itemNum" type="hidden" id="itemNum" value="<%= itemCount%>" />
                    <tr class="tdbg" align="center" style="height: 28px;">
                        <td colspan="8">
                            <div class="mis_pager">

                                <script type="text/javascript">Page.SetPager(<%=recordCount %>, <%=pageIndex %>, <%=pageSize %>, window.location.href.split("?")[0], "page", "");</script>

                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                    </tr>
                </table>

 

后台:
        public int pageSize = 6;
        public int pageIndex = 1;
        public int recordCount = 0;
        public int itemCount = 0;

 

 

          if (Convert.ToInt32(Request.QueryString["page"]) > 1)
             {
                 pageIndex = Convert.ToInt32(Request.QueryString["page"]);
             }

    List<FullBusService> infoList;
          infoList = misService.GetFullBusServiceList(BusServiceSortOption.addTimeDesc, pageSize, pageIndex, ref recordCount, CacheTimeOption.None);
          itemCount = infoList.Count;
          rpResources.DataSource = infoList;
          rpResources.DataBind();

原创粉丝点击