WebForm分頁瀏覽

2022-09-17 18:42:12 字數 3091 閱讀 5789

1.封裝類

//

封裝類using

system;

using

system.collections.generic;

using

system.web;

//////

users 的摘要說明

///public

class

users

set

}private

string

_password;

public

string

password

set

}private

string

_nickname;

public

string

nickname

set

}private

bool

_***;

public

bool

***

set

}public

string

secstr

}private

datetime _birthday;

public

datetime birthday

set

}public

string

birthdaystr

}private

string

_nation;

public

string

nation

set }}

view code

2連線資料庫,建立方法

using

system;

using

system.collections.generic;

using

system.web;

using

system.data.sqlclient;

//////

userdata 的摘要說明

///public

class

userdata

//////

查詢資料庫所有內容

/// ///

泛型集合

public listquan()

cnn.close();

return

ulist;

}//////

/// ///

第幾頁 ///

每一頁的數量

///public listselect(int dijiye,int

perpagenum)

}cnn.close();

return

ulist;

}//////

根據sql語句,查詢符合條件的資料

/// ///

sql查詢條件

///public listzuhe(string

sql)

cnn.close();

return

ulist;}}

view code

3.頁面設定

c#" autoeventwireup="

true

" codefile="

default1.aspx.cs

" inherits="

default1

" %>

"">

view code

4、設定事件

using

system;

using

system.collections.generic;

using

system.web;

using

system.web.ui;

using

system.web.ui.webcontrols;

public

partial

class

default1 : system.web.ui.page}}

void dropdownlist1_selectedindexchanged(object sender, eventargs e)//

索引變化事件

void xiayiye_button_click(object sender, eventargs e)//

repeater1.datasource = new userdata().select

(xia,pagecount);

repeater1.databind();

dijiye.text =xia.tostring();

}void shangyiye_click(object sender, eventargs e)//

repeater1.datasource = new userdata().select

(shang, pagecount);

repeater1.databind();

dijiye.text =shang.tostring();

}public

int maxpage()//

求最多有多少頁

else

return

i; }

}

view code

總之:就是拼sql查詢語句:

每頁5行資料

select top 5  * from users where username not in(select top 0 username from users);顯示第一頁資訊

select top 5  * from users where username not in(select top 5 username from users);顯示第二頁資訊

以此類推。。。。。。。

select top " + perpagenum + " * from users where username not in(select top " + (perpagenum*(dijiye - 1)) + " username from users)

完!!!

PHP實現分頁瀏覽功能

入門級 class pages 方法名 db select 說明 執行資料庫連線以及sql查詢 返回值 查詢所得結果集 public function db select sql else return res mysqli close 方法名 print pages 引數 per page row...

js實現簡單分頁瀏覽

最後實現如下 裡面還沒有磚塊,用js動態插入 這個是底下的導航 共x頁 var a math.floor math.random 10 50 var fatherbox document.getelementbyid bigbox for var i 0 i a i function gopage ...

WebForm傳送郵件

using system using system.collections.generic using system.linq using system.web using system.net.mail using system.configuration using system.net usi...