- 爱易网页
-
ASP.NET教程
- DataList的分页有关问题~
日期:2014-05-18 浏览次数:20392 次
求助DataList的分页问题~~~
我的程序代码如下:
就是往名为Score的DataList中加入分页
using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class food : System.Web.UI.Page
{
private int cPage = 2;
OleDbConnection MyConn;
int PageSize, RecordCount, PageCount, CurrentPage;
public void Page_Load(Object src, EventArgs e)
{
//设定PageSize
PageSize = cPage;
//连接语句
string MyConnString = CStatic.getStrconn();
MyConn = new OleDbConnection(MyConnString);
MyConn.Open();
//第一次请求执行
if (!Page.IsPostBack)
{
CurrentPage = 0;
ViewState[ "PageIndex "] = 0;
//计算总共有多少记录
RecordCount = CalculateRecord();
// lblRecordCount.Text = RecordCount.ToString();
//计算总共有多少页
PageCount = (RecordCount / PageSize) + 1;
ViewState[ "PageCount "] = PageCount;
ListBind();
}
}
//计算总共有多少条记录
public int CalculateRecord()
{
int intCount;
int iID = 0;
try