<asp:Repeater ID="Repeater1" runat="server">
<Itemtemplate>
<div style="padding:5px;background-color:#dedede">
[<%# DataBinder.Eval(Container.DataItem, "uid") %>]
<%# DataBinder.Eval(Container.DataItem, "Title") %> Posted AT :
<%# DataBinder.Eval(Container.DataItem, "addtime") %>
</div>
</Itemtemplate>
</asp:Repeater>
=====================================
private void Page_Load(object sender, System.EventArgs e)
{
// //建立连接
// System.Data.SqlClient.SqlConnection mConnection;
// mConnection = new System.Data.SqlClient.SqlConnection();
// mConnection.ConnectionString="Data Source = localhost;User ID=sa;Password=;Initial Catalog=News";
// mConnection.Open();
//
// //DataAdapter
// System.Data.SqlClient.SqlCommand vCommand=mConnection.CreateCommand();
// System.Data.SqlClient.SqlDataAdapter vAdapter = new System.Data.SqlClient.SqlDataAdapter();
// vCommand.CommandText="SELECT * FROM [_news]"; // + "AND [NodeID]=" + iRootID.ToString();
// vAdapter.SelectCommand=vCommand;
// //DataSet
// DataSet ds=new DataSet();
// vAdapter.Fill(ds);
Logic lg = new Logic();
DataTable dt00 = lg.GetAllNews();
// this.PagingRepeater1.DataSource = dt00;
// this.PagingRepeater1.DataBind();
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = dt00.DefaultView;//ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 10;
int CurPage;
if (Request.QueryString["Page"] != null)
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1;
objPds.CurrentPageIndex = CurPage-1;
lblCurrentPage.Text = "当前页:" + CurPage.ToString();
if (!objPds.IsFirstPage)
lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage-1);
if (!objPds.IsLastPage)
lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page=" + Convert.ToString(CurPage+1);
Repeater1.DataSource=objPds;
Repeater1.DataBind();
}
本文地址:http://com.8s8s.com/it/it8828.htm