日期:2014-05-20  浏览次数:20560 次

请问这样的分页怎么做??
首页   上一页   1   2   3   4   5   6   下一页   末页

请问上面这样的分页怎么做?绑定DataList的

------解决方案--------------------
写个循环了...
------解决方案--------------------
<%@ Import Namespace= "Wuqi.Webdiyer " %> 陕西吴旗
http://www.webdiyer.com/webdiyer/files.asp
先要去下载个Webdiyer.dll控件 然后添加控件 就ok了
------解决方案--------------------
下一个 AspNetPager60 分页控件,很好用

------解决方案--------------------
我想你可能主要是中间页码比较难实现吧,我以前做过个
主要通过循环给label控件加页码。
for(int i =1;i <=pageTotal;i++)
{
if(pageNumber != i)
{
this.lblPageNum.Text += " <a href=\ "javascript:ChangePage( "+i+ ")\ "> "+i+ " </a> &nbsp; ";
}
else
{
this.lblPageNum.Text +=i+ "&nbsp; ";
}
}
ChangePage()这个函数主要是将点击的页码数再次传给页面
------解决方案--------------------
下一个 AspNetPager60 分页控件,很好用
------解决方案--------------------
下一个 AspNetPager60 分页控件,很好用

------解决方案--------------------
我刚自己写了一个,大致就是这样的,你看看:

//绑定数据到DataList
public void BindData()
{


int iPageNow = Convert.ToInt32(lPage.Text);

string strSQL = "select * from [note] order by ID desc ";

PagedDataSource pds = new PagedDataSource();
pds.DataSource = myData.OleDbCmdRtnTB(strSQL).DefaultView;

pds.AllowPaging = true; //允许分页
pds.PageSize = 3;
if (iPageNow+1 > pds.PageCount)
{
pds.CurrentPageIndex = pds.PageCount-1;
lPage.Text = Convert.ToString(pds.PageCount-1);
}
else
{
pds.CurrentPageIndex = iPageNow;
}


//输出页码

if (pds.PageCount > 1)
{
string strPages = " <img src= 'images/index/trans_10px.gif ' width= '10 ' height= '10 ' /> ";

for (int i = 1; i <= pds.PageCount; i++)
{
if (i == pds.CurrentPageIndex + 1)
{
strPages += " <a href= 'note_list.aspx?page= " + i + " ' class= 'red_big '> " + i + " </a> <img src= 'images/index/trans_10px.gif ' width= '10 ' height= '10 ' /> ";
}
else
{
strPages += " <a href= 'note_list.aspx?page= " + i + " ' class= 'FBlack '> " + i + " </a> <img src= 'images/index/trans_10px.gif ' width= '10 ' height= '10 ' /> ";
}
}

lPageNum.Text = strPages;

bPre.Visible = true;
bNext.Visible = true;

bDelAll.Visible = true;
lDel.Visible = true;

}
else
{
bPre.Visible = false;
bNext.Visible = false;
}



//下面主要是控制上下翻页按纽是否起用
bPre.Enabled = true;
bNext.Enabled = true;