I.页面代码
<table class="listtable">
<tr class="thead">
<td>标题</td>
<td>时间</td>
</tr>
<asp:Repeater ID="SQLDataGrid" runat="server">
<ItemTemplate>
<tr
οnmοuseοver="this.style.backgroundColor='#CCCCCC'"
οnmοuseοut="this.style.backgroundColor='#ffffff'">
<td><%# Eval("PE_CommonModel.Title")%></td>
<td><%# Eval("PE_U_pv.UpDateTime")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td>
<webdiyer:AspNetPager ID="Pager" runat="server"
NextPageText="Next" PrevPageText="Previous"
SubmitButtonText="Go" InvalidPageIndexErrorMessage="page index
must be number!!"
PageIndexOutOfRangeErrorMessage="page index can not exceed the
range!!"
PageIndexBoxType="TextBox"
ShowPageIndexBox="Always" TextBeforePageIndexBox="Go to page"
TextAfterPageIndexBox="" ShowCustomInfoSection="Never"
Font-
Underline="False" ShowDisabledButtons="true"
HorizontalAlign="Right" Wrap="False"
ShowNavigationToolTip="True" FirstPageText="|<"
LastPageText=">|" ShowMoreButtons="False">
</webdiyer:AspNetPager>
</td>
</tr>
</table>
II.cs
protected void Page_Load(object sender, EventArgs e)
{
If(!isPostBack){
BindData();
}
}
private void BindData(){
tring connstr = "Data Source=127.0.0.1;Initial
Catalog=VedioExp;uid=sa;pwd=123456;";
SqlConnection conn = new SqlConnection(connstr);//实例化连接
string cmd = "select * FROM PE_CommonModel,PE_U_pv where
PE_CommonModel.GeneralID=PE_U_pv.ID order by
PE_CommonModel.GeneralID desc";
SqlDataAdapter sda = new SqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
sda.Fill(ds);
this.Pager.RecordCount = DS.Tables(0).Rows.Count;
this.Pager.PageSize = 10;
PagedDataSource pageDS=New PagedDataSource();
pageDS.DataSource = DS.Tables(0).DefaultView;
pageDS.AllowPaging = True
pageDS.CurrentPageIndex = Pager.CurrentPageIndex - 1;
pageDS.PageSize = Pager.PageSize;
SQLDataGrid.DataSource = pageDS;
SQLDataGrid.DataBind();
}
III,在Pager_PageChanged事件放入BindData();即可.