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 System.Collections;
public partial class _Default : System.Web.UI.Page {
public static string all;
public ArrayList list = new ArrayList();
public static int count;//ÓÃÓÚͳ¼ÆÖй²Óм¸Ò³
protected void Page_Load(object sender, EventArgs e) {
//½«ÐèÒªµÄÄÚÈÝÈ«²¿ÌáÈ¡³öÀ´ string strConn \"server=WIN-VS34GCN26UK\\\\SQLEXPRESS;database=build;Pwd=1990522wxl;Uid=WLR\";
SqlConnection conn = new SqlConnection(strConn); conn.Open();
SqlCommand cmd = new SqlCommand(); cmd.Connection = conn;
cmd.CommandText = \"select count(*) from fangyuan\";
object o = cmd.ExecuteScalar(); all = o.ToString(); }
//ÒÔÏÂÊÇ·ÖÒ³´úÂë public void pages() {
try {
//½«ÐèÒªµÄÄÚÈÝÈ«²¿ÌáÈ¡³öÀ´ string strConn \"server=WIN-VS34GCN26UK\\\\SQLEXPRESS;database=build;Pwd=1990522wxl;Uid=WLR\";
SqlConnection conn = new SqlConnection(strConn);
= = conn.Open();
SqlCommand cmd = new SqlCommand(); cmd.Connection = conn;
cmd.CommandText = \"select * from fangyuan\"; SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt);
//ÿһ´ÎÔÚÄÚ´æÖÐÌáÈ¡ÐèÒªµÄ²¿·Ö
PagedDataSource pds = new PagedDataSource();//PagedDataSource·ÖÒ³ÊÇÀà pds.DataSource = dt.DefaultView;//¸ø·ÖÒ³Ö¸¶¨Êý¾ÝÔ´ pds.PageSize = 2;//ÿҳÏÔʾÁ½ÌõÊý¾Ý pds.AllowPaging = true;//ÊÇ·ñÔÊÐí·ÖÒ³
pds.CurrentPageIndex = Convert.ToInt32(this.Label1.Text);//ÏÔʾµÚÒ»Ò³
//½«pds°ó¶¨µ½¿Ø¼þÖÐÈ¥
this.Repeater1.DataSource = pds; this.Repeater1.DataBind();
count=(dt.Rows.Count-1)/2;
for (int i = 0; i <= count; i++) {
list.Add(i); }
this.DropDownList1.DataSource = list; this.DropDownList1.DataBind(); }
catch (Exception ex) {
Response.Write(ex.Message); } }
protected void LinkButton1_Click(object sender, EventArgs e) {
this.Label1.Text = \"0\";
this.DropDownList1.Text = this.Label1.Text; this.pages();//ÖØÐµ÷Ó÷ÖÒ³ }
protected void LinkButton2_Click(object sender, EventArgs e) {
string str = this.Label1.Text;//È¡³öÏÖÔÚµÄÒ³Êý
if (!str.Equals(\"0\")) {
int next = Convert.ToInt32(str) - 1;//µ±ÆÚÒ³Êý-1 this.Label1.Text = next.ToString();//±£³Öµ±ÆÚÒ³Êý this.DropDownList1.Text = this.Label1.Text; this.pages();//ÖØÐµ÷Ó÷ÖÒ³ } else {
Response.Write(\"ÒѾ-ÊÇÊ×Ò³ÁË£¡£¡\"); } }
protected void LinkButton3_Click(object sender, EventArgs e) {
string str = this.Label1.Text;//È¡³öÏÖÔÚµÄÒ³Êý int num = Convert.ToInt32(all) / 2; if (!str.Equals(num.ToString())) {
int next = Convert.ToInt32(str) + 1;//µ±ÆÚÒ³Êý+1 this.Label1.Text = next.ToString();//±£³Öµ±ÆÚÒ³Êý this.DropDownList1.Text = this.Label1.Text; this.pages();//ÖØÐµ÷Ó÷ÖÒ³ } else {
Response.Write(\"ÒѾ-ÊÇĩҳÁË£¡£¡\"); } }
protected void LinkButton4_Click(object sender, EventArgs e) {
int num1 = Convert.ToInt32(all)/2; string num2 = Convert.ToString(num1); this.Label1.Text = num2;
this.DropDownList1.Text = this.Label1.Text; this.pages(); }
protected void Button1_Click(object sender, EventArgs e) {
this.pages(); }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
string str=this.DropDownList1.SelectedValue; this.Label1.Text=str;
this.DropDownList1.Text = str; this.pages(); } }
<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"Default.aspx.cs\" Inherits=\"_Default\" %>
ÈÌ¿´Åó±²³ÉÐÂ¹í£¬Å-Ïòµ¶´ÔÃÙСʫ¡£±ÊÂ侪·çÓ꣬ʫ³ÉÆü¹íÉñ¡£
因篇幅问题不能全部显示,请点此查看更多更全内容