zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    BZOJ5212 ZJOI2018历史(LCT)
    BZOJ5127 数据校验
    253. Meeting Rooms II
    311. Sparse Matrix Multiplication
    254. Factor Combinations
    250. Count Univalue Subtrees
    259. 3Sum Smaller
    156. Binary Tree Upside Down
    360. Sort Transformed Array
    348. Design Tic-Tac-Toe
  • 原文地址:https://www.cnblogs.com/wenghaowen/p/3287585.html
Copyright © 2011-2022 走看看