关于分页生成html??????
新闻列表比如news.aspx?page=1,news.aspx?page=2,news.aspx?page=3
不考虑用重写。。。。
怎么用代码来实现生成new_1.html,new_2.html,new_3.html
很急!在此求教!
------解决方案-------------------- private void PageDisplay()
{
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter sda = new SqlDataAdapter();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
conn.ConnectionString = "server=.;pwd=sa;uid=sa;database=Northwind ";
cmd.Connection = conn;
cmd.CommandText = "select OrderId,EmployeeID,OrderDate,RequiredDate,ShippedDate from orders ";
sda.SelectCommand = cmd;
sda.Fill(ds, "Em ");
dt = ds.Tables[0];
nRecCount = dt.Rows.Count;
StringBuilder sb = new StringBuilder( " ");
if(nRecCount > 0)
{
PageCount = nRecCount / 10;
if(nRecCount / 10 > 0)
{
PageCount++;
}
if(this.Request.QueryString[ "page "] == null)
{
nPage = 1;
}
else
{
this.nPage = int.Parse(this.Request.QueryString[ "page "]);
}if(this.nPage < 1)
{
nPage = 1;
}
if(this.nPage > this.PageCount)
{
this.nPage = this.PageCount;
}
if(nPage == 1)
{
sb.Append( " <a href= 'WebForm1.aspx?page=1 '> 首页 </a> ")
.Append( " <a href= 'WebForm1.aspx?page= ")
.Append(nPage + 1)
.Append( " '> 下一页 </a> ")
.Append( " <a href= 'WebForm1.aspx?page= ")
.Append(PageCount)
.Append( " '> 尾页 </a> ")
.Append( " 页次: ")
.Append(nPage.ToString())
.Append( "/ ")
.Append(PageCount.ToString())
.Append( " <br> ");
}
else
if(nPage == PageCount)
{
sb.Append( " <a href= 'WebForm1.aspx?page=1 '> 首页 </a> ")
.Append( " <a href= 'WebForm1.aspx?page= ")
.Append(nPage - 1)
.Append( " '> 上一页 </a> ")
.Append( " <a href= 'WebForm1.aspx?page= ")
.Append(PageCount)
.Append( " '> 尾页 </a> ")
.Append( " 页次: ")
.Append(nPage.ToString())
.Append( "/ ")
.Append(PageCount.ToString())
.Append( " <br> ");
}
else
{
sb.Append( " <a href= 'WebForm1.aspx?page=1 '> 首页 </a> ")
.Append( " <a href= 'WebForm1.aspx?page= ")
.Append(nPage - 1)
.Append( " '> 上一页 </a> ")
.Append( " <a href= 'WebForm1.aspx?page= ")
.Append(nPage + 1)
.Append( " '> 下一页 </a> ")
.Append( " <a href= 'WebForm1.aspx?page= ")
.Append(PageCount)
.Append( " '> 尾页 </a> ")
.Append( " 页次: ")
.Append(nPage.ToString())
.Append( "/ ")
.Append(PageCount.ToString())
.Append( " <br> &quo