乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Repeater使用 AspNetPager分頁控件

       滅星之破 2012-02-10

      一、AspNetPager分頁控件

      分頁是Web應(yīng)用程序中最常用到的功能之一,在ASP.NET中,雖然自帶了一個可以分頁的DataGrid(asp.net 1.1)和GridView(asp.net 2.0)控件,但其分頁功能并不盡如人意,如可定制性差、無法通過Url實現(xiàn)分頁功能等,而且有時候我們需要對DataList和Repeater甚至自定義數(shù)據(jù)綁定控件進行分頁,手工編寫分頁代碼不但技術(shù)難度大、任務(wù)繁瑣而且代碼重用率極低,因此分頁已成為許多ASP.NET程序員最頭疼的問題之一。

      AspNetPager針對ASP.NET分頁控件的不足,提出了與眾不同的解決asp.net中分頁問題的方案,即將分頁導(dǎo)航功能與數(shù)據(jù)顯示功能完全獨立開來,由用戶自己控制數(shù)據(jù)的獲取及顯示方式,因此可以被靈活地應(yīng)用于任何需要實現(xiàn)分頁導(dǎo)航功能的地方,如為GridView、DataList以及Repeater等數(shù)據(jù)綁定控件實現(xiàn)分頁、呈現(xiàn)自定義的分頁數(shù)據(jù)以及制作圖片瀏覽程序等,因為AspNetPager控件和數(shù)據(jù)是獨立的,因此要分頁的數(shù)據(jù)可以來自任何數(shù)據(jù)源,如SQL Server、Oracle、Access、mysql、DB2等數(shù)據(jù)庫以及XML文件、內(nèi)存數(shù)據(jù)或緩存中的數(shù)據(jù)、文件系統(tǒng)等等。

      二、基本屬性:

      AlwaysShow:

      默認情況下,當要分頁的數(shù)據(jù)只有一頁時,AspNetPager默認會自動危險期而不在頁面上顯示任何可見內(nèi)容,將此屬性值設(shè)為true時,即使總頁數(shù)只有一頁,AspNetPager也將顯示分頁導(dǎo)航元素。

      FirstPageText:

      獲取或設(shè)置為第一頁按鈕顯示的文本。

      LastPageText:

      獲取或設(shè)置為最后一頁按鈕顯示的文本。

      NextPageText:

      獲取或設(shè)置為下一頁按鈕顯示的文本。

      PrevPageText:

      獲取或設(shè)置為上一頁按鈕顯示的文本。

      PageSize:

      獲取或設(shè)置每頁顯示的項數(shù)。(該值獲取或設(shè)置數(shù)據(jù)呈現(xiàn)控件每次要顯示數(shù)據(jù)表中的的數(shù)據(jù)的項數(shù),AspNetPager根據(jù)該值和 RecordCount 來計算顯示所有數(shù)據(jù)需要的總頁數(shù),即 PageCount的值。 )

      CssClass:

      應(yīng)用于控件的css類名

      CurrentPageButtonClass:

      獲取或設(shè)置AspNetPager分頁控件當前頁導(dǎo)航按鈕的級聯(lián)樣式表 (CSS) 類。

      PageIndexBoxType:

      或者或設(shè)置頁索引框的顯示類型,可以是允許用戶手工輸入的文本框和只能選擇的下拉框。

      ShowBoxThreshold:

      當 ShowPageIndexBox 設(shè)為Auto(默認)并且要分頁的數(shù)據(jù)的總頁數(shù)達到該值時會自動顯示頁索引輸入文本框,默認值為30。該選項當 ShowPageIndexBox 設(shè)為Never或Always時沒有任何作用。

       

      三、風格樣式:

      ===== 網(wǎng)易風格 =====

      .anpager .cpb {background:#1F3A87 none repeat scroll 0 0;border:1px solid #CCCCCC;color:#FFFFFF;font-weight:bold;margin:5px 4px 0 0;padding:4px 5px 0;}

      .anpager a {background:#FFFFFF none repeat scroll 0 0;border:1px solid #CCCCCC;color:#1F3A87;margin:5px 4px 0 0;padding:4px 5px 0;text-decoration:none}

      .anpager a:hover{background:#1F3A87 none repeat scroll 0 0;border:1px solid #1F3A87;color:#FFFFFF;}

      屬性設(shè)置:CssClass="anpager" CurrentPageButtonClass="cpb"

      ===== 拍拍網(wǎng)風格 =====

      .paginator { font: 11px Arial, Helvetica, sans-serif;padding:10px 20px 10px 0; margin: 0px;}

      .paginator a {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;margin-right:2px}

      .paginator a:visited {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}

      .paginator .cpb {padding: 1px 6px;font-weight: bold; font-size: 13px;border:none}

      .paginator a:hover {color: #fff; background: #ffa501;border-color:#ffa501;text-decoration: none;}

      屬性設(shè)置:CssClass="paginator" CurrentPageButtonClass="cpb"

      ===== 迅雷風格 =====

      .pages { color: #999; }

      .pages a, .pages .cpb { text-decoration:none;float: left; padding: 0 5px; border: 1px solid #ddd;background: #ffff;margin:0 2px; font-size:11px; color:#000;}

      .pages a:hover { background-color: #E61636; color:#fff;border:1px solid #E61636; text-decoration:none;}

      .pages .cpb { font-weight: bold; color: #fff; background: #E61636; border:1px solid #E61636;}

      屬性設(shè)置:CssClass="pages" CurrentPageButtonClass="cpb"

       

      四、如何調(diào)用:

      index.aspx文件

       

       

      <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

      <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

      <%@ Register src="hand.ascx" tagname="hand" tagprefix="uc1" %>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www./1999/xhtml">
      <head runat="server">
          <title></title>
          <link href="inc/css.css" rel="stylesheet" type="text/css" />
         
          <style type="text/css">
          /*網(wǎng)易風格*/
          .anpager .cpb {background:#1F3A87 none repeat scroll 0 0;border:1px solid #CCCCCC;color:#FFFFFF;font-weight:bold;margin:5px 4px 0 0;padding:4px 5px 0;}
          .anpager a {background:#FFFFFF none repeat scroll 0 0;border:1px solid #CCCCCC;color:#1F3A87;margin:5px 4px 0 0;padding:4px 5px 0;text-decoration:none}
          .anpager a:hover{background:#1F3A87 none repeat scroll 0 0;border:1px solid #1F3A87;color:#FFFFFF;}

          /*拍拍網(wǎng)風格*/
          .paginator { font: 11px Arial, Helvetica, sans-serif;padding:10px 20px 10px 0; margin: 0px;}
          .paginator a {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;margin-right:2px}
          .paginator a:visited {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
          .paginator .cpb {padding: 1px 6px;font-weight: bold; font-size: 13px;border:none}
          .paginator a:hover {color: #fff; background: #ffa501;border-color:#ffa501;text-decoration: none;}

          /*迅雷風格*/
          .pages { color: #999 }
          .pages a, .pages .cpb { text-decoration:none;float: left; padding: 0 5px; border: 1px solid #ddd;background: #ffff;margin:0 2px; font-size:11px; color:#000;}
          .pages a:hover { background-color: #E61636; color:#fff;border:1px solid #E61636; text-decoration:none;}
          .pages .cpb { font-weight: bold; color: #fff; background: #E61636; border:1px solid #E61636;}

          .code{font-weight:bold;color:blue}
          </style>
      </head>
      <body>
          <form id="form1" runat="server">
          <uc1:hand ID="hand1" runat="server" />
         
          <div style="text-align:left; line-height:20px">
          <asp:Repeater ID="SoftDown" runat="server">
              <ItemTemplate>
                  <div style="border-bottom:1px solid #000000"><%#Eval("E_id")%> <%#Eval("Class")%><br><%#Eval("DownTitle")%><br><%#Eval("PageHome")%></div>
              </ItemTemplate>
          </asp:Repeater>
         
              <div style="text-align:right; padding-top:10px">
             
              <webdiyer:AspNetPager ID="AspNetPager1" runat="server" pagesize="5" CssClass="anpager" onpagechanged="AspNetPager1_PageChanged"
                  FirstPageText="首頁" LastPageText="尾頁" NextPageText="下一頁" PrevPageText="上一頁"
                  ShowMoreButtons="False" ShowPageIndexBox="Never">
              </webdiyer:AspNetPager></div>
          </div>
          </form>
      </body>
      </html>

       

       

      index.aspx.cs

      using System;
      using System.Collections;
      using System.Configuration;
      using System.Data;
      using System.Linq;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.HtmlControls;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Xml.Linq;
      using System.Data.SqlClient;
      using GHSqlConn;
      using Wuqi.Webdiyer;


      public partial class Default2 : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack) {
                  SqlConnection conn = DB.getConnection();
                  conn.Open();
                  SqlCommand Count = new SqlCommand();
                  Count.Connection = conn;
                  Count.CommandText = "select count(*) from T_SoftDown1";
                  AspNetPager1.RecordCount = (int)Count.ExecuteScalar();
                  //Response.Write(AspNetPager1.RecordCount);
                  conn.Close();
                  BindData();
              }

          }

          public void BindData()
          {
              SqlConnection conn = DB.getConnection();
              string sql = "select * from T_SoftDown1 order by E_id desc";//這句在大型數(shù)據(jù)中應(yīng)該用:select top查詢語句
              SqlDataAdapter da = new SqlDataAdapter(sql, conn);
              DataSet ds = new DataSet();
              da.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "temptbl");
              DataTable dt = ds.Tables["temptbl"];
              SoftDown.DataSource=dt;
              SoftDown.DataBind();
          }

          protected void AspNetPager1_PageChanged(object src, EventArgs e)
          {
              //AspNetPager1.CurrentPageIndex = e.NewPageIndex;
              BindData();
          }
      }

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多