A pagination of Repeater, I don't know how efficiency?

xiaoxiao2021-03-06  90

] <% # DataBinder.eval (Container.DataItem, "Title")%> Posted at: <% # DataBinder.eval (Container.DataItem, "Addtime")%> < / ASP: REPEATER>

=====================================

private void Page_Load (object sender, System.EventArgs e) {// // establish a connection // 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 (); dataable dt00 = lg.getallnews (); // this.pagingrepeater1.datasource = dt00; // this.pagingrepeater1.database ();

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 =" this page: " 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 ();

转载请注明原文地址:https://www.9cbs.com/read-123379.html

New Post(0)