學了這麼久的
[html]
<asp:ListView ID=
<LayoutTemplate>
<table border=
<thead>
<tr>
<td>用戶名</td>
<td>密碼</td>
</tr>
</thead>
<tbody>
<asp:PlaceHolder runat=
</tbody>
</table>
<asp:DataPager runat=
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton=
FirstPageText=
NextPageText=
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%#Eval(
<td><%#Eval(
</tr>
</ItemTemplate>
</asp:ListView>
<asp:PlaceHolder runat=
NextPreviousPagerField
幾個重要參數如下
pagesize:每頁顯示的記錄數
ButtonCount:顯示的分頁數
PreviousPageText:
NextPageText:
FirstPageText:
LastPageText:
下面是我寫的幾種分頁模板
[html]
<asp:NextPreviousPagerField ShowFirstPageButton=
FirstPageText=
NextPageText=
<asp:NumericPagerField ButtonCount=
<asp:TemplatePagerField>
<PagerTemplate>
<b>
第
<asp:Label runat=
Text=
頁 共
<asp:Label runat=
Text=
(
共<asp:Label runat=
Text=
條記錄)
<br />
</b>
</PagerTemplate>
</asp:TemplatePagerField>
<asp:NextPreviousPagerField
ButtonType=
ShowFirstPageButton=
ShowNextPageButton=
ShowPreviousPageButton=
<asp:NumericPagerField
PreviousPageText=
NextPageText=
ButtonCount=
<asp:NextPreviousPagerField
ButtonType=
ShowLastPageButton=
ShowNextPageButton=
ShowPreviousPageButton=
下面是aspx頁面的全部代碼
[html] <%@ Page Language=
<!DOCTYPE html PUBLIC
<html xmlns=
<head runat=
<title>無標題頁</title>
<style>
table
{
border
}
</style>
</head>
<body>
<form id=
<asp:ObjectDataSource ID=
DeleteMethod=
OldValuesParameterFormatString=
TypeName=
UpdateMethod=
<DeleteParameters>
<asp:Parameter Name=
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name=
<asp:Parameter Name=
<asp:Parameter Name=
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name=
<asp:Parameter Name=
</InsertParameters>
</asp:ObjectDataSource>
<div>
<asp:ListView ID=
<LayoutTemplate>
<table border=
<thead>
<tr>
<td>用戶名</td>
<td>密碼</td>
</tr>
</thead>
<tbody>
<asp:PlaceHolder runat=
</tbody>
</table>
<asp:DataPager runat=
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton=
FirstPageText=
NextPageText=
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%#Eval(
<td><%#Eval(
</tr>
</ItemTemplate>
</asp:ListView>
</div>
</form>
</body>
</html>
<%@ Page Language=
<!DOCTYPE html PUBLIC
<html xmlns=
<head runat=
<title>無標題頁</title>
<style>
table
{
border
}
</style>
</head>
<body>
<form id=
<asp:ObjectDataSource ID=
DeleteMethod=
OldValuesParameterFormatString=
TypeName=
UpdateMethod=
<DeleteParameters>
<asp:Parameter Name=
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name=
<asp:Parameter Name=
<asp:Parameter Name=
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name=
<asp:Parameter Name=
</InsertParameters>
</asp:ObjectDataSource>
<div>
<asp:ListView ID=
<LayoutTemplate>
<table border=
<thead>
<tr>
<td>用戶名</td>
<td>密碼</td>
</tr>
</thead>
<tbody>
<asp:PlaceHolder runat=
</tbody>
</table>
<asp:DataPager runat=
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton=
FirstPageText=
NextPageText=
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%#Eval(
<td><%#Eval(
</tr>
</ItemTemplate>
</asp:ListView>
</div>
</form>
</body>
</html>
代碼我上傳到資源裡大家自己下載吧
From:http://tw.wingwit.com/Article/program/net/201311/11786.html