急,急,急分页问题???
public int Record_Per_Page; //定义每页显示记录数
int nPageCount; //定义总页数
int nRecCount; //定义总记录数
int nPage; //定义当前页
//获得总记录数
nRecCount = pd.GetObjectCountByTime(timeStart, timeEnd);
StringBuilder strHtml = new StringBuilder("");
//取得当前页数,并判断
if (Request["pagesize"] == null)
Record_Per_Page = 25;
else
Record_Per_Page = Convert.ToInt32(Request["pagesize"]);
//判断是否存在数据记录
if (nRecCount > 0)
{
//确定数据记录要显示的页面数
nPageCount = nRecCount / Record_Per_Page;
if (nRecCount % Record_Per_Page > 0)
nPageCount++;
if (nPage < 1)
nPage = 1;
if (nPage > nPageCount)
nPage = nPageCount;
//将页面显示到屏幕上,并作连接
for (int i = 1; i < nPageCount; i++)
{
strHtml.Append("<a href='Dengji.aspx?page=" + i + "×tart=" + timeStart.ToString("yyyy-MM-dd") + "&timeend=" + timeEnd.ToString("yyyy-MM-dd") + " '>");
//strHtml.Append("<a href='Dengji.aspx?page=" + i + "'>");
if (i == nPage) strHtml.Append("<b>" + i + "</b>");
else strHtml.Append(i);
strHtml.Append("</a> ");
}
//确认当前页面的开始记录和终止记录
int nStart = Record_Per_Page * (nPage - 1);
int nEnd = nStart + Record_Per_Page - 1;
if (nEnd > nRecCount - 1)
nEnd = nRecCount - 1;
strlnk = strHtml.ToString();
StrSql.AppendFormat("SELECT distinct TOP {0} * FROM C_Work_Object WHERE ", Record_Per_Page.ToString());
StrSql.AppendFormat("( Obj_id NOT IN (SELECT TOP {0} Obj_id FROM C_Work_Object", (Record_Per_Page * (nPage - 1)).ToString());
StrSql.Append(" ORDER BY Obj_id DESC)");
strSql.Append(" ORDER BY Obj_id DESC");
pdperson = pd.GetObjectBySql(StrSql.ToString() +strSql.ToString() );
这是我写的一个手工分页代码,设置的每页显示的记录数是25条,但现在的问题是当页面计算出来多余的记录数大于或少于25条时,都不显示,哪位大狭帮指点一下啊,怎么改正啊???多谢~~