日期:2014-05-18  浏览次数:20445 次

想找一个分页程序的代码谁能给我一个啊?谢谢了
希望给我一个带 代码的例子我是新手 

  分页效果最好就象这个论坛一样的 共500篇 共4页 1 2 3 4 5 6 
  
  类似这样的 也可发我邮箱 melack@163.com

  谢谢了!!!

------解决方案--------------------
自己做的分页控件 :
public partial class WebUserControl : System.Web.UI.UserControl
{

private string imagePreUrl;
/// <summary>
/// 上一页的图片地址
/// </summary>
public string ImagePrevUrl
{
get
{
return imagePreUrl;
}
set
{
this.imagePreUrl = value;
}
}


private string imageNextUrl;
/// <summary>
/// 下一页的图片地址
/// </summary>
public string ImageNextUrl
{
get
{
return imageNextUrl;
}
set
{
this.imageNextUrl = value;
}
}

private string pageName;
/// <summary>
/// 使用分页的页面名称,注意?后带参数的需要自行修改
/// </summary>
public string PageName
{
get
{
return pageName;
}
set
{
this.pageName = value;
}
}

/// <summary>
/// 分页大小
/// </summary>
private int pageSize;
public int PageSize
{
get
{
return pageSize;
}
set
{
this.pageSize = value;
}
}

/// <summary>
/// 可见连接的个数
/// </summary>
private int visibilityPageCount;
public int VisibilityPageCount
{
get
{
return visibilityPageCount;
}
set
{
this.visibilityPageCount = value;
}
}

string currentPageUrl = "";

protected void Page_Load(object sender, EventArgs e)
{

}

public PagedDataSource BindGrid(DataView dataView)
{
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = dataView;
objPds.AllowPaging = true;
objPds.PageSize = pageSize;
int CurPage;
if (Request.QueryString["Page"] != null)
{
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
if (CurPage > objPds.PageCount)
{
CurPage = 1;
}
}
else
{
CurPage = 1;
}
this.lblPageCount.Text = objPds.PageCount.ToString();

currentPageUrl = Request.Url.PathAndQuery;
if (currentPageUrl.Contains("Page="))
{
currentPageUrl = currentPageUrl.Remove(currentPageUrl.LastIndexOf("Page=") - 1);
}
if (currentPageUrl.Contains("?"))
{
currentPageUrl += "&Page=";
}
else
{
currentPageUrl += "?Page=";
}

this.PageAStr(CurPage, objPds.PageCount);

objPds.CurrentPageIndex = CurPage - 1;
lblCurrentPage.Text = CurPage.ToString();



// string RootPath = (Request.ApplicationPath != "/") ? Request.ApplicationPath + "/" : Request.ApplicationPath;
if (!objPds.IsFirstPage)
{
lnkPrev.NavigateUrl = currentPageUrl + Convert.ToString(CurPage - 1);
}

if (!objPds.IsLastPage)
{