string
conn
=
"
server=192.168.0.5;uid=sa;pwd=;database=ComputerSchool
"
;
protected void Page_Load( object sender, EventArgs e)
... {
if (!IsPostBack)
...{
int totalOrders = Convert.ToInt32(o());
AspNetPager1.RecordCount = totalOrders;
AspNetPager1.CustomInfoHTML = "记录总数:<font color="blue"><b>" + AspNetPager1.RecordCount.ToString() + "</b></font>";
AspNetPager1.CustomInfoHTML += " 总页数:<font color="blue"><b>" + AspNetPager1.PageCount.ToString() + "</b></font>";
AspNetPager1.CustomInfoHTML += " 当前页:<font color="red"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>";
AspNetPager1.CurrentPageIndex = 0;
bindData();
}
}
public object o()
... {
string sqlStr = "select count(userID) from answerPaper";
return SqlHelper.ExecuteScalar(conn,CommandType.Text,sqlStr);
}
public DataSet answerPaper()
... {
string sqlStr = String.Format(" Select Top {0} * From answerPaper where courseID+catalogID+contentID Not in ( Select Top {1} courseID+catalogID+contentID From answerPaper Order By contentID)", AspNetPager1.PageSize.ToString(), (this.AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize);
return SqlHelper.ExecuteDataset(conn, CommandType.Text, sqlStr);
}
private void bindData()
... {
GridView1.DataSource = answerPaper();
GridView1.DataBind();
}
protected void AspNetPager1_PageChanged( object sender, EventArgs e)
... {
bindData();
}
protected void Page_Load( object sender, EventArgs e)
... {
if (!IsPostBack)
...{
int totalOrders = Convert.ToInt32(o());
AspNetPager1.RecordCount = totalOrders;
AspNetPager1.CustomInfoHTML = "记录总数:<font color="blue"><b>" + AspNetPager1.RecordCount.ToString() + "</b></font>";
AspNetPager1.CustomInfoHTML += " 总页数:<font color="blue"><b>" + AspNetPager1.PageCount.ToString() + "</b></font>";
AspNetPager1.CustomInfoHTML += " 当前页:<font color="red"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>";
AspNetPager1.CurrentPageIndex = 0;
bindData();
}
}
public object o()
... {
string sqlStr = "select count(userID) from answerPaper";
return SqlHelper.ExecuteScalar(conn,CommandType.Text,sqlStr);
}
public DataSet answerPaper()
... {
string sqlStr = String.Format(" Select Top {0} * From answerPaper where courseID+catalogID+contentID Not in ( Select Top {1} courseID+catalogID+contentID From answerPaper Order By contentID)", AspNetPager1.PageSize.ToString(), (this.AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize);
return SqlHelper.ExecuteDataset(conn, CommandType.Text, sqlStr);
}
private void bindData()
... {
GridView1.DataSource = answerPaper();
GridView1.DataBind();
}
protected void AspNetPager1_PageChanged( object sender, EventArgs e)
... {
bindData();
}