Repeater、ListView控件与AspNetPaper、asp:DataPager分页控件的详解和注意

首先Repeater可以与AspNetPaper实现简单的分页,因为aspnetpaper不支持回发,所以只能用在简单的展示上面

 

在用AspNetPaper的时候要注意的是,必须先绑定的是RecourCourt,就是必须先绑定的是有几条数据,之后才会计算出有几页,现在第几页等
之后再绑定数据

 

另外Repeater除了与AspNetPaper结合能分页外,asp.net自带的分页控件是不能支持Repeater的分页的,所以一般在表格的自定义样式的情况下

我们选择ListView去替换Repeater的使用具体使用如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PartyIntercourseList.aspx.cs"
    Inherits="ZWW.Web.PartyRepresentatives.PartyIntercourseList" MasterPageFile="~/PartyRepresentatives/ddbgzs.Master" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="gzsWrap">
        <div class="alTitle">
            <h1>
                回复列表页</h1>
        </div>
        <div class="alContent">
            <div class="det_box">
                <span>党代表工作室:</span><asp:DropDownList ID="ddl_org" runat="server"
                    AutoPostBack="true">
                </asp:DropDownList>
                <span>意见建议:</span><asp:TextBox ID="tb_partyname" runat="server"></asp:TextBox>
                <asp:Button ID="btn_Search" runat="server" CssClass="btn_cs" Text="查 询" />&nbsp;
                <asp:Button ID="btn_SearchAll" runat="server" CssClass="btn_cs" Text="查询所有" OnClick="btn_SearchAll_Click" />
            </div>
            <div class="ly_box">
                <asp:ListView runat="server" ID="repList" DataSourceID="ods_party">
                    <LayoutTemplate>
                        <table border="0" cellspacing="0" cellpadding="0" class="ly_table">
                            <tr>
                                <th>
                                    党代表工作室
                                </th>
                                <th>
                                    意见建议
                                </th>                                                                
                                <th>
                                    办理结果
                                </th>
                                <th>
                                    接待时间
                                </th>
                            </tr>
                            <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                          </table>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <tr>
                            <td class="w0">
                                <%#DataBinder.Eval(Container.DataItem, "ORG_NAME")%>
                            </td>                            
                            <td>
                                <a href='PartyIntercourseDetail.aspx?intercourseid=<%#Eval("INTERACTION_ID") %>'
                                    target="_blank">
                                    <%#DataBinder.Eval(Container.DataItem, "Q_CONTENT")%></a>
                            </td>
                            <td>
                                已办理
                            </td>
                            <td class="w1">
                               <%#Eval("A_TIME","{0:yyyy-MM-dd}") %>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:ListView>
                <div class="alPage">
                     <asp:DataPager ID="dp_party" runat="server" PagedControlID="repList" PageSize="7"
                            EnableViewState="false">
                            <Fields>
                                <asp:TemplatePagerField>
                                    <PagerTemplate><%= DataCount%>条记录, 当前第<asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.TotalRowCount>0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0 %>" />/<asp:Label
                                            runat="server" ID="TotalPagesLabel" Text="<%# Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize) %>" />页,
                                    </PagerTemplate>
                                </asp:TemplatePagerField>
                                <asp:NextPreviousPagerField ButtonType="Image" ShowFirstPageButton="true" ShowPreviousPageButton="true"
                                    ShowLastPageButton="false" ShowNextPageButton="false" FirstPageText="首页" ButtonCssClass="PageCss"
                                    PreviousPageText="上页" FirstPageImageUrl="images/page1.png" PreviousPageImageUrl="images/page3.png" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ButtonType="Image" ShowNextPageButton="true" ShowLastPageButton="true"
                                    ShowFirstPageButton="false" ShowPreviousPageButton="false" LastPageText="末页"
                                    ButtonCssClass="PageCss" LastPageImageUrl="images/page2.png" NextPageImageUrl="images/page4.png"
                                    NextPageText="下页" />
                            </Fields>
                        </asp:DataPager>
                        <asp:ObjectDataSource ID="ods_party" runat="server" SelectMethod="GetPartySpokesmanInteractionData"
                            TypeName="ZWW.BLL.PartySpokesmanManage" MaximumRowsParameterName="pageSize" StartRowIndexParameterName="startIndex"
                            EnablePaging="True" SelectCountMethod="GetPartySpokesmanInteractionDataAmount" EnableViewState="false">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="ddl_org" Name="orgID" PropertyName="SelectedValue"
                                    Type="Int32" />
                                <asp:ControlParameter ControlID="tb_partyname" Name="qContent" Type="String" />
                                <asp:Parameter Name="contentCount" Type="Int32" DefaultValue="40" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                </div>
            </div>
        </div>
    </div>
</asp:Content>

 

 

转载于:https://www.cnblogs.com/wenghaowen/p/3287585.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值