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

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

    • 分享

      .NET實(shí)現(xiàn)Repeater控件+AspNetPager控件分頁(yè)

       昵稱(chēng)48397323 2017-10-17

      SqlConnection (.NET C#) 連接及分頁(yè) 
      .net的訪(fǎng)問(wèn)數(shù)據(jù)機(jī)制決定了訪(fǎng)問(wèn)大量數(shù)據(jù)時(shí)會(huì)致使客戶(hù)端機(jī)器消耗大量資源,因此有必要對(duì)數(shù)據(jù)進(jìn)行分頁(yè)顯示,開(kāi)發(fā)工具vs.net+sqlserver,語(yǔ)言c#

      1.加入引用

      將AspNetPager控件引入到項(xiàng)目中,即在aspx頁(yè)面里添加引用,把AspNetPager的dll文件加到Bin文件夾目錄下
      using System.Data.SqlClient;
      using Wuqi.Webdiyer;

      2.前臺(tái)顯示頁(yè)面aspx

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

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

      <!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>無(wú)標(biāo)題頁(yè)</title>
          <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
      </head>
      <body>
          <form id="form1" runat="server">
          <div>
              <asp:Repeater ID="Repeater1" runat="server">
              <HeaderTemplate><ul></HeaderTemplate>
                  <ItemTemplate>
                      <li><%#"客戶(hù)ID: "+Eval("customerid") %>      <%#"公司名稱(chēng): "+Eval("companyname") %>      <%#"聯(lián)系地址: "+Eval("address") %></li>
                  </ItemTemplate>
              <FooterTemplate></ul></FooterTemplate>
              </asp:Repeater>
              <br />
              <webdiyer:AspNetPager ID="AspNetPager1" runat="server" FirstPageText="" LastPageText=""
                  NextPageText="下一頁(yè)" OnPageChanging="AspNetPager1_PageChanging" CssClass="pages" CurrentPageButtonClass="cpb" PrevPageText="上一頁(yè)">
              </webdiyer:AspNetPager>
          </div>
          </form>
      </body>
      </html>

      3.后臺(tái)代碼部分aspx.cs

      using System;
      using System.Data;
      using System.Configuration;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Web.UI.HtmlControls;
      using System.Data.SqlClient;
      using Wuqi.Webdiyer;

      public partial class _Default : System.Web.UI.Page 
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  bindsql();
              }
          }
          private void bindsql()
          {
              SqlConnection con = new SqlConnection("Data Source=20090731-5465;Initial Catalog=Northwind;Integrated Security=True");
              con.Open();
              SqlDataAdapter sqlda = new SqlDataAdapter("select * from customers", con);
              DataSet ds = new DataSet();
              sqlda.Fill(ds);
              PagedDataSource pdsList = new PagedDataSource();
              pdsList.DataSource = ds.Tables[0].DefaultView;
              pdsList.AllowPaging = true;//數(shù)據(jù)源允許分頁(yè)
              pdsList.PageSize = this.AspNetPager1.PageSize;//取控件的分頁(yè)大小
              pdsList.CurrentPageIndex = this.AspNetPager1.CurrentPageIndex - 1;//顯示當(dāng)前頁(yè)
              //設(shè)置控件
              this.AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;//記錄總數(shù)
              this.AspNetPager1.PageSize = 10;
              this.Repeater1.DataSource = pdsList;
              this.Repeater1.DataBind();

          }
          protected void AspNetPager1_PageChanging(object src, PageChangingEventArgs e)
          {
              AspNetPager1.CurrentPageIndex = e.NewPageIndex;
              bindsql();
          }
      }

      4.CSS文件樣式表

      body {
      }
      .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;}

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

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約

        類(lèi)似文章 更多