新人散分:100分求ASP.NET分页源码。

windelement 2008-12-05 10:44:52
想找一个分页的源码学习一下。请大家帮忙。数据库是SQL2000的,表的内容随意。要求:分页显示为: 第一页 1 2 3 4 5....最后页 共XX页 运行环境:VS2005
请将源码发送到邮箱 291117621@qq.com
...全文
721 37 打赏 收藏 转发到动态 举报
写回复
用AI写文章
37 条回复
切换为时间正序
请发表友善的回复…
发表回复
dralion 2010-04-10
  • 打赏
  • 举报
回复
很好啊 貌似都测试过了不啊
deng1230 2010-01-27
  • 打赏
  • 举报
回复
顶上
carlos_zhang 2009-04-01
  • 打赏
  • 举报
回复
作为一名有理想\有抱负的程序员,只用别人做好的控件来实现效果.那你可以离开这个圈了.因为这里不适合你生存.因为你不理解他真正的内涵.你只是山寨.
楼主.不要听他们乱来.既然学了.就要学精.相信你..

呵呵..喝多了..看到一些人的回复狠是不爽.都说中国人制造不出原创.这能制造出来么??全是用别人的.根本没有想过diy..
a123553628 2008-12-05
  • 打赏
  • 举报
回复
其实想不用空间实现 分页还是很简单的
chinaxc 2008-12-05
  • 打赏
  • 举报
回复
调用的方法,
/// <summary>
/// 存储过程
/// </summary>
/// <param name="webcons">WebControl绑定控件</param>
/// <param name="dbtable">表名</param>
/// <param name="pagesize">每页显示记录数</param>
/// <param name="showsize">每页显示分页数</param>
/// <param name="thispage">当前页索引</param>
/// <returns>分页字串</returns>
public string GetPorc(WebControl webcons,string dbtable,int pagesize,int showsize,int thispage)
{
MAYI.Mpage Mypage = new MAYI.Mpage();
Open();
SqlCommand cmd = new SqlCommand("Mypage", Connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@metabname", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@mepagesize", SqlDbType.Int);
cmd.Parameters.Add("@mepageint", SqlDbType.Int);
cmd.Parameters.Add("@thispage", SqlDbType.Int);

cmd.Parameters["@metabname"].Value = "news";
cmd.Parameters["@mepagesize"].Value = pagesize;
cmd.Parameters["@mepageint"].Value = showsize;
cmd.Parameters["@thispage"].Value = thispage;


cmd.Parameters.Add("@msrsall", SqlDbType.Int);
cmd.Parameters.Add("@mspagecount", SqlDbType.Int);

cmd.Parameters["@msrsall"].Direction = ParameterDirection.Output;
cmd.Parameters["@mspagecount"].Direction = ParameterDirection.Output;

cmd.ExecuteNonQuery();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
if (webcons is GridView)
{
(webcons as GridView).DataSource= ds.Tables[0].DefaultView;
(webcons as GridView).DataBind();
}

if (webcons is DataList)
{
(webcons as DataList).DataSource = ds.Tables[0].DefaultView;
(webcons as DataList).DataBind();
}

string pagestr = Mypage.MyPage(Convert.ToInt32(cmd.Parameters["@msrsall"].Value), pagesize, showsize, null, null, "pp", null, null, null);
return pagestr;
Close();
}
chinaxc 2008-12-05
  • 打赏
  • 举报
回复
配合数字分页的存储过程

CREATE PROCEDURE Mypage
(
@metabname varchar(200), --表名
@mepagesize int, --每页显示记录数
@mepageint int, --分页条显示个数
@thispage int, --当前页编号

@msrsall int output, --总记录数
@mspagecount int output --总页数
)
AS
declare @tabsql nvarchar(200)
declare @pagecount int --分页总数
declare @rsall int --总记录数
declare @top int --提当前段数据
declare @sql varchar(200)
------------------------------------------------------------------------------------
set @tabsql='select @rsall =count(*) from '+ @metabname
exec sp_executesql @tabsql,N'@rsall int output',@rsall output
------------------------------------------------------------------------------------
if @rsall >0 --有数据
begin
set @top=@mepagesize*(@thispage-1)
set @sql='select top ' + str(@mepagesize) + ' * from '+@metabname+' where id not in(select top '+ str(@top) +' id from '+@metabname+') order by id asc'
exec(@sql)
if @rsall % @mepagesize=0
begin
set @pagecount=@rsall / @mepagesize
end
else
begin
set @pagecount=@rsall / @mepagesize+1
end
end
else --没数据
begin
set @msrsall=0
set @mspagecount=0
end
set @msrsall=@rsall --总信息数
set @mspagecount=@pagecount --分页总数
GO
chinaxc 2008-12-05
  • 打赏
  • 举报
回复
文字分页

public string Mepage(int Mcount, int pagesize, string Mepostbackurl, string Meurlstr, string Meurlpage)
{
int num;
int num2;
StringBuilder builder = new StringBuilder();
string str = Meurlstr + Meurlpage;
if ((HttpContext.Current.Request.QueryString[Meurlpage] != null) && int.TryParse(HttpContext.Current.Request.QueryString[Meurlpage], out num))
{
num2 = Convert.ToInt32(HttpContext.Current.Request.QueryString[Meurlpage]);
}
else
{
num2 = 1;
}
int num3 = Mcount / pagesize;
if (num3 == 0)
{
num3 = 1;
}
else if ((Mcount % pagesize) > 0)
{
num3++;
}
builder.Append("<table><tr>");
builder.Append("<td>");
builder.Append("共有条" + Mcount.ToString() + "记录 ");
builder.Append(string.Concat(new object[] { "当前是第", num2, "/", num3, "页 " }));
if (num3 == 1)
{
builder.Append("首页 ");
builder.Append("上一页 ");
builder.Append("下一页 ");
builder.Append("最后一页");
}
else if (num2 == 1)
{
builder.Append("首页 ");
builder.Append("上一页 ");
builder.Append(string.Concat(new object[] { "<a href=", Mepostbackurl, "?", str, "=", num2 + 1, ">下一页</a> " }));
builder.Append(string.Concat(new object[] { "<a href=", Mepostbackurl, "?", str, "=", num3, ">最后一页</a>" }));
}
else if (num2 >= num3)
{
builder.Append("<a href=" + Mepostbackurl + "?" + str + "=1>首页</a> ");
builder.Append(string.Concat(new object[] { "<a href=", Mepostbackurl, "?", str, "=", num2 - 1, ">上一页</a> " }));
builder.Append("下一页 ");
builder.Append("最后一页");
}
else
{
builder.Append("<a href=" + Mepostbackurl + "?" + str + "=1>首页</a> ");
builder.Append(string.Concat(new object[] { "<a href=", Mepostbackurl, "?", str, "=", num2 - 1, ">上一页</a> " }));
builder.Append(string.Concat(new object[] { "<a href=", Mepostbackurl, "?", str, "=", num2 + 1, ">下一页</a> " }));
builder.Append(string.Concat(new object[] { "<a href=", Mepostbackurl, "?", str, "=", num3, ">最后一页</a>" }));
}
builder.Append("</td>");
builder.Append("<td><select id=\"MeSelectPage\" onchange=\"window.location='" + Mepostbackurl + "?" + str + "='+this.options[this.selectedIndex].value\">\r\n");
for (int i = 1; i < (num3 + 1); i++)
{
if ((HttpContext.Current.Request.QueryString[Meurlpage] != null) && (HttpContext.Current.Request.QueryString[Meurlpage].ToString() == i.ToString()))
{
builder.Append(string.Concat(new object[] { "<option value=", i, " selected>", i, "页</option>\r\n" }));
}
else
{
builder.Append(string.Concat(new object[] { "<option value=", i, ">", i, "页</option>\r\n" }));
}
}
builder.Append("</select></td>\r\n");
builder.Append("</tr></table>");
return builder.ToString();
}
chinaxc 2008-12-05
  • 打赏
  • 举报
回复
数字分页

public string MyPage(int Myallcount, int Mypagesize, int Mypageshowsize, string Mypostbackurl, string Myurlstr, string Myurlpage, string Mycolor, string Myfontcolor, string Mybordercolor)
{
StringBuilder builder = new StringBuilder();
StringBuilder builder2 = new StringBuilder();
string str = Myurlstr + Myurlpage;
int num = Myallcount / Mypagesize;
if (num == 0)
{
num = 1;
}
else if ((Myallcount % Mypagesize) > 0)
{
num++;
}
int num3 = 0;
if (Myallcount > 0)
{
int num2;
int num4;
int num5;
builder.Append("<td class=pagefalse><a href=#>共有" + Myallcount + "条记录</a></td>\r\n");
builder.Append("<td class=pagefalse><a href=" + Mypostbackurl + "?" + str + "=1 title=首页>首页</a></td>\r\n");
if (!(((HttpContext.Current.Request.QueryString[Myurlpage] != null) && (HttpContext.Current.Request.QueryString[Myurlpage].ToString() != null)) && int.TryParse(HttpContext.Current.Request.QueryString[Myurlpage], out num4)))
{
num2 = 1;
}
else
{
num2 = Convert.ToInt32(HttpContext.Current.Request.QueryString[Myurlpage]);
}
if (num < Mypageshowsize)
{
for (num5 = (num2 / Mypageshowsize) + 1; num5 <= num; num5++)
{
if (num2 == num5)
{
builder.Append("<td class=pagetrue><a href=" + Mypostbackurl + "?" + str + "=" + num5.ToString() + " title=第" + num5.ToString() + "页>" + num5.ToString() + "</a></td>\r\n");
}
else
{
builder.Append("<td class=pagefalse><a href=" + Mypostbackurl + "?" + str + "=" + num5.ToString() + " title=第" + num5.ToString() + "页>" + num5.ToString() + "</a></td>\r\n");
}
}
}
else if ((num2 / Mypageshowsize) > 0)
{
builder.Append(string.Concat(new object[] { "<td class=pagefalse><a href=", Mypostbackurl, "?", str, "=", Convert.ToInt32((int) (((num2 / Mypageshowsize) * Mypageshowsize) - 1)), " title=上一组>.....</a></td>\r\n" }));
if ((num2 / Mypageshowsize) < (num / Mypageshowsize))
{
for (num5 = (num2 / Mypageshowsize) * Mypageshowsize; num5 <= (((num2 / Mypageshowsize) + 1) * Mypageshowsize); num5++)
{
if (num2 == num5)
{
builder.Append("<td class=pagetrue><a href=" + Mypostbackurl + "?" + str + "=" + num5.ToString() + " title=第" + num5.ToString() + "页>" + num5.ToString() + "</a></td>\r\n");
}
else
{
builder.Append("<td class=pagefalse><a href=" + Mypostbackurl + "?" + str + "=" + num5.ToString() + " title=第" + num5.ToString() + "页>" + num5.ToString() + "</a></td>\r\n");
}
}
num3 = ((num2 / Mypageshowsize) + 1) * Mypageshowsize;
builder.Append("<td class=pagefalse><a href=" + Mypostbackurl + "?" + str + "=" + num3.ToString() + " title=下一组>.....</a></td>\r\n");
}
else
{
for (num5 = (num2 / Mypageshowsize) * Mypageshowsize; num5 <= num; num5++)
{
if (num2 == num5)
{
builder.Append("<td class=pagetrue><a href=" + Mypostbackurl + "?" + str + "=" + num5.ToString() + " title=第" + num5.ToString() + "页>" + num5.ToString() + "</a></td>\r\n");
}
else
{
builder.Append("<td class=pagefalse><a href=" + Mypostbackurl + "?" + str + "=" + num5.ToString() + " title=第" + num5.ToString() + "页>" + num5.ToString() + "</a></td>\r\n");
}
}
num3 = num;
}
}
else
{
for (num5 = (num2 / Mypageshowsize) + 1; num5 <= Mypageshowsize; num5++)
{
if (num2 == num5)
{
builder.Append("<td class=pagetrue><a href=" + Mypostbackurl + "?" + str + "=" + num5.ToString() + " title=第" + num5.ToString() + "页>" + num5.ToString() + "</a></td>\r\n");
}
else
{
builder.Append("<td class=pagefalse><a href=" + Mypostbackurl + "?" + str + "=" + num5.ToString() + " title=第" + num5.ToString() + "页>" + num5.ToString() + "</a></td>\r\n");
}
}
num3 = ((num2 / Mypageshowsize) + 1) * Mypageshowsize;
builder.Append("<td class=pagefalse><a href=" + Mypostbackurl + "?" + str + "=" + num3.ToString() + " title=下一组>.....</a></td>\r\n");
}
builder.Append("<td><select id=\"MySelectPage\" onchange=\"window.location='" + Mypostbackurl + "?" + str + "='+this.options[this.selectedIndex].value\">\r\n");
for (int i = 1; i < (num + 1); i++)
{
if ((HttpContext.Current.Request.QueryString[Myurlpage] != null) && (HttpContext.Current.Request.QueryString[Myurlpage].ToString() == i.ToString()))
{
builder.Append(string.Concat(new object[] { "<option value=", i, " selected>", i, "页</option>\r\n" }));
}
else
{
builder.Append(string.Concat(new object[] { "<option value=", i, ">", i, "页</option>\r\n" }));
}
}
builder.Append("</select></td>\r\n");
builder.Append(string.Concat(new object[] { "<td class=pagefalse><a href=", Mypostbackurl, "?", str, "=", num, " title=最后一页>最后一页</a></td>\r\n" }));
}
else
{
builder.Append("<td>抱歉没有数据</td>");
}
builder2.Append("<style>\r\n");
builder2.Append(".pageborder A:active,.pageborder A:hover,.pageborder A:visited,.pageborder A:link {\r\n");
builder2.Append("DISPLAY: block;COLOR: #686868;TEXT-DECORATION: none;font-size:14px;text-align:center;\r\n");
builder2.Append("border: 1px solid " + Mybordercolor + ";}\r\n");
builder2.Append(".pagefalse A:link,.pagefalse A:visited,.pagefalse A:active,.pagefalse A:hover {padding:3px;}\r\n");
builder2.Append(".pagetrue A:link,.pagetrue A:visited,.pagetrue A:active,.pagetrue A:hover {\r\n");
builder2.Append("padding:5px;background-color:" + Mycolor + ";color:" + Myfontcolor + ";}\r\n");
builder2.Append("</style>\r\n");
builder2.Append("<table cellspacing=0 class=pageborder>\r\n");
builder2.Append("<tr>\r\n");
builder2.Append(builder.ToString() + "\r\n");
builder2.Append("</tr>\r\n");
builder2.Append("</table>\r\n");
return builder2.ToString();
}
浮生若梦丶 2008-12-05
  • 打赏
  • 举报
回复

public SqlDataReader getBatchSale(Int32 id, int iSize, int iIndex, bool bDocount, string strCondition)
{
SqlDataReader dataReader = null;
database data = new database();
SqlParameter[] prams = {
data.MakeInParam("@id",SqlDbType.BigInt,8,id), //用作条件,用户id(可选)
data.MakeInParam("@pagesize",SqlDbType.Int,4,iSize),//每页显示条数
data.MakeInParam("@pageindex",SqlDbType.Int,4,iIndex),//第几页
data.MakeInParam("@docount",SqlDbType.Bit,1,bDocount),//是否统计数据
data.MakeInParam("@condition",SqlDbType.VarChar,800,strCondition) //其他条件(可选)
};
try
{
data.RunProc("sp_member_BatchSale", prams, out dataReader);
return (dataReader);
}
catch (Exception ex)
{
Error.Log(ex.ToString());
return null;
}
finally
{
data = null;
}
}


============存储过程

CREATE PROCEDURE sp_member_BatchSale

@id bigint,
@pagesize int,
@pageindex int,
@docount bit,
@condition varchar(800)

AS
set nocount on

if(@docount=1)
exec('select count(*) FROM web_C_BatchSale C_BatchSale inner join web_C_Customer c on c.CustomerID = C_BatchSale.CustomerID
left join Common_DCode on Common_DCode.DCode=c.AreaCode where C_BatchSale.UpUserID='+@id+@condition)
else
begin
declare @PageLowerBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
if(@PageLowerBound=0)
exec('SELECT top 20 C_BatchSale.CustomerID as "C_BatchSale.CustomerID",
c.CustomerName as "C_BatchSale.CustomerName",
Common_DCode.DName,
C_BatchSale.BatchSaleNumber as "C_BatchSale.BatchSaleNumber",
Convert(varchar(10),C_BatchSale.SaleDate,120) as "C_BatchSale.SaleDate",
C_BatchSale.BSTypesCode as "C_BatchSale.BSTypesCode",
C_BatchSale.CarryModeCode as "C_BatchSale.CarryModeCode",
C_BatchSale.ReceiveModeCode as "C_BatchSale.ReceiveModeCode",
C_BatchSale.ReceiveStateCode as "C_BatchSale.ReceiveStateCode",
C_BatchSale.Operator as "C_BatchSale.Operator",
C_BatchSale.AddDate as "C_BatchSale.AddDate",
convert(numeric(8,2),round(C_BatchSale.TotalFixedPrice,2)) as "C_BatchSale.TotalFixedPrice",
convert(numeric(8,2),round(C_BatchSale.TotalDiscountedPrice,2)) as "C_BatchSale.TotalDiscountedPrice",
convert(numeric(8,2),round(C_BatchSale.AverageRebate,2)) as "C_BatchSale.AverageRebate",
C_BatchSale.AllowSendBackCode as "C_BatchSale.AllowSendBackCode",
C_BatchSale.StateCode as "C_BatchSale.StateCode",
C_BatchSale.TotalCount as "C_BatchSale.TotalCount",
C_BatchSale.Remark as "C_BatchSale.Remark"
FROM web_C_BatchSale C_BatchSale inner join web_C_Customer c on c.CustomerID = C_BatchSale.CustomerID
left join Common_DCode on Common_DCode.DCode=c.AreaCode
where C_BatchSale.UpUserID='+@id+@condition+'
ORDER BY C_BatchSale.OrderID')
else
begin
exec('SELECT top 20 C_BatchSale.CustomerID as "C_BatchSale.CustomerID",
c.CustomerName as "C_BatchSale.CustomerName",
Common_DCode.DName,
C_BatchSale.BatchSaleNumber as "C_BatchSale.BatchSaleNumber",
Convert(varchar(10),C_BatchSale.SaleDate,120) as "C_BatchSale.SaleDate",
C_BatchSale.BSTypesCode as "C_BatchSale.BSTypesCode",
C_BatchSale.CarryModeCode as "C_BatchSale.CarryModeCode",
C_BatchSale.ReceiveModeCode as "C_BatchSale.ReceiveModeCode",
C_BatchSale.ReceiveStateCode as "C_BatchSale.ReceiveStateCode",
C_BatchSale.Operator as "C_BatchSale.Operator",
C_BatchSale.AddDate as "C_BatchSale.AddDate",
convert(numeric(8,2),round(C_BatchSale.TotalFixedPrice,2)) as "C_BatchSale.TotalFixedPrice",
convert(numeric(8,2),round(C_BatchSale.TotalDiscountedPrice,2)) as "C_BatchSale.TotalDiscountedPrice",
convert(numeric(8,2),round(C_BatchSale.AverageRebate,2)) as "C_BatchSale.AverageRebate",
C_BatchSale.AllowSendBackCode as "C_BatchSale.AllowSendBackCode",
C_BatchSale.StateCode as "C_BatchSale.StateCode",
C_BatchSale.TotalCount as "C_BatchSale.TotalCount",
C_BatchSale.Remark as "C_BatchSale.Remark"
FROM web_C_BatchSale C_BatchSale inner join web_C_Customer c on c.CustomerID = C_BatchSale.CustomerID
left join Common_DCode on Common_DCode.DCode=c.AreaCode
where C_BatchSale.UpUserID='+@id+@condition+'
and C_BatchSale.orderID>(select max(OrderID) From
(Select top '+@PageLowerBound+' C_BatchSale.OrderID FROM web_C_BatchSale C_BatchSale inner join web_C_Customer c
on c.CustomerID = C_BatchSale.CustomerID left join Common_DCode on Common_DCode.DCode=c.AreaCode
where C_BatchSale.UpUserID='+@id+@condition+'
ORDER BY C_BatchSale.orderID
) As ENGINE_CHILDQUERY_TEMPTABLE)
ORDER BY C_BatchSale.orderID')
end
end
set nocount off
GO

============================上面那是未优化过的分页函数,下面是优化过的,你自己对着修改,结贴给分

CREATE PROCEDURE sp_memberCenter_BookStock
@id int,
@pagesize int,
@pageindex int,
@docount bit,
@condition varchar(800)

AS
set nocount on

if(@docount=1)
exec('select count(*) from web_publish_Books_Storage a inner join web_publish_books b
on a.booknumber=b.booknumber where b.upuserid='+@id+@condition)

else
begin --select * from common_code where codeid=7
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
set @PageLowerBound=@PageLowerBound+1
exec('declare @indextable table(id int identity(1,1),nid int)
insert into @indextable(nid) select a.BookNumber from web_publish_Books_Storage a inner join web_publish_books b
on a.booknumber=b.booknumber where b.upuserid='+@id+@condition+' order by a.adddate desc

SELECT a.booknumber,storagevalues,instoragetotal,a.adddate,bookname,
(SELECT typesname FROM web_B_BookTypes z where b.BookTypeCode=z.typesid)as booktypecode,author,
(select codename from common_code c where c.codeid=7 and a.SaleState=c.code) as SaleState,
Convert(numeric(10,2),price) as price
FROM web_publish_Books_Storage a inner join web_publish_books b
on a.booknumber=b.booknumber,@indextable t
where b.upuserid='+@id+@condition+' and a.BookNumber=t.nid
and t.id between '+@PageLowerBound+' and '+@PageUpperBound+'
order by t.id ')
end
set nocount off
GO

mrhu7002 2008-12-05
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 fly_to_the_winds 的回复:]
============== .cs 方法

C# code
/// <summary>
/// 分页绑定
/// </summary>
/// <param name="strTCondition"></param>
private void GridTotal(string strTCondition)
{

SqlDataReader drStorage = member.getBatchSale(Convert.ToInt32(Session["user_id"]), 1, 1, true, strTCondition);
while (drStorage.Read())
{

[/Quote]

支持!!!
浮生若梦丶 2008-12-05
  • 打赏
  • 举报
回复
============== .cs 方法

/// <summary>
/// 分页绑定
/// </summary>
/// <param name="strTCondition"></param>
private void GridTotal(string strTCondition)
{

SqlDataReader drStorage = member.getBatchSale(Convert.ToInt32(Session["user_id"]), 1, 1, true, strTCondition);
while (drStorage.Read())
{
Pager.RecordCount = Convert.ToInt32(drStorage[0].ToString());
}
drStorage.Close();
}

/// <summary>
/// gridview绑定
/// </summary>
/// <param name="strGCondition"></param>
private void BindGrid(string strGCondition)
{

SqlDataReader drStorage = member.getBatchSale(Convert.ToInt32(Session["user_id"]), Pager.PageSize, Pager.CurrentPageIndex, false, strGCondition);

DataTable dtStorage = tools.ConvertDataReaderToDataTable(drStorage);
dtStorage.TableName = "BatchSale";
grid_List.DataSource = dtStorage.DefaultView;
grid_List.DataBind();
lblNum.Text = Pager.RecordCount.ToString();
}
/// <summary>
/// 分页控件分页事件
/// </summary>
/// <param name="src"></param>
/// <param name="e"></param>
protected void Pager_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
Pager.CurrentPageIndex = e.NewPageIndex;
BindGrid(strCondition);
}
浮生若梦丶 2008-12-05
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 niitnanfeng 的回复:]
分页控件,邹建大侠的aspnetpager最好用。
[/Quote]

<div class="content" style="width: 776px; text-align: left">

<div style="overflow-x: scroll; overflow-y: hidden;width: 776px; ">
<asp:GridView ID="grid_List" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="C_BatchSale.BatchSaleNumber"
CellPadding="4" OnDataBound="grid_List_DataBound" PageSize="20" Width="1400px" OnRowDeleting="grid_List_RowDeleting" OnRowDataBound="grid_List_RowDataBound" BorderColor="#93BEE2" BorderStyle="Solid">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="C_BatchSale.CustomerID" DataNavigateUrlFormatString="CustomerInfo.aspx?id={0}"
DataTextField="C_BatchSale.CustomerName" HeaderText="客户名称">
<ItemStyle Width="150px" />
</asp:HyperLinkField>
<asp:BoundField DataField="DName" HeaderText="所属区域">
<ItemStyle Width="140px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.BatchSaleNumber" HeaderText="批销单号">
<ItemStyle Width="90px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.SaleDate" DataFormatString="{0:d}" HeaderText="批销日期">
<ItemStyle Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.BSTypesCode" HeaderText="批销类型">
<ItemStyle Width="53px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.CarryModeCode" HeaderText="发货方式">
<ItemStyle Width="53px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.ReceiveStateCode" HeaderText="收款情况">
<ItemStyle Width="53px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.Operator" HeaderText="操作员">
<ItemStyle Width="53px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.TotalFixedPrice" HeaderText="总码洋">
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.TotalDiscountedPrice" HeaderText="总实洋">
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.AverageRebate" HeaderText="平均折扣">
<ItemStyle Width="53px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.AllowSendBackCode" HeaderText="允许退货">
<ItemStyle Width="53px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.StateCode" HeaderText="单据状态">
<ItemStyle Width="53px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.TotalCount" HeaderText="本单数量">
<ItemStyle Width="53px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.AddDate" HeaderText="添加日期">
<ItemStyle Width="120px" />
</asp:BoundField>
<asp:BoundField DataField="C_BatchSale.Remark" Visible="False" HeaderText="备注"/>
<asp:HyperLinkField DataNavigateUrlFields="C_BatchSale.BatchSaleNumber" DataNavigateUrlFormatString="AddBatchSale.aspx?bid={0}&type=upd"
HeaderText="修改" Text="修改">
<ItemStyle Width="30px" />
</asp:HyperLinkField>
<asp:TemplateField HeaderText="删除">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
OnClientClick='return confirm("您确定要删除这条记录吗?")' Text="删除"></asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="30px" />
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#859FD4" Font-Bold="False" ForeColor="White" />
</asp:GridView>
</div>
<div style="margin-top: 0px; font-size: 12px; letter-spacing: 2px; text-align: right;
text-decoration: none">
<webdiyer:aspnetpager id="Pager" runat="server" alwaysshow="True" cssclass="" custominfosectionwidth="10%"
custominfotext="" custominfotextalign="Justify" imagepath="/" inputboxclass="txtnav" NumericButtonTextFormatString="[{0}]"
inputboxstyle="txtnav" onpagechanged="Pager_PageChanged" pagesize="20" pagingbuttonspacing="80px"
showcustominfosection="Left" showinputbox="Always" submitbuttonclass="btn1nav"
submitbuttonstyle="btn1nav" textafterinputbox="页 " textbeforeinputbox="第">
</webdiyer:aspnetpager>
</div>
</div>
leaf_2008 2008-12-05
  • 打赏
  • 举报
回复
用aspnetpager啊,这个是免费的,什么都不用写啊,生成存储过程也可以在网站上生成啊
网址http://www.webdiyer.com/AspNetPager/default.aspx
笺香 2008-12-05
  • 打赏
  • 举报
回复
顶啊。来学习
niitnanfeng 2008-12-05
  • 打赏
  • 举报
回复
分页控件,邹建大侠的aspnetpager最好用。
greatverve 2008-12-05
  • 打赏
  • 举报
回复
首先,没有必要这么做,用控件多好。如果真需要了,给你一个。我现在已经不用这个了。

/// <summary>
/// 分页函数
/// </summary>
/// <param name="pageSize">每页记录记录数</param>
/// <param name="navNum">数字页码显示个数</param>
/// <param name="firstPage">首页</param>
/// <param name="prevPage">上页</param>
/// <param name="nextPage">下页</param>
/// <param name="lastPage">末页</param>
/// <param name="leftHtml">页码左边内容</param>
/// <param name="rightHtml">页码右边内容</param>
/// <param name="outerSpace">首上下末间空格</param>
/// <param name="innerSpace">数字页码间空格</param>
/// <param name="urlParam">要转向的URL地址,须加?号</param>
/// <param name="tableKey">表的主键</param>
/// <param name="tableName">表的名称</param>
/// <param name="theField">表的字段</param>
/// <param name="theWhere">以where开头,不能为空</param>
/// <param name="theOrder">排序语句,可为空</param>
/// <param name="currentPage">当前页,从1开始</param>
/// <param name="cmdParam">含参数的Command对象</param>
/// <param name="objs">参数列表</param>
public static Hashtable ExecutePage(int pageSize, int navNum, string firstPage, string prevPage, string nextPage, string lastPage, string leftHtml, string rightHtml, string outerSpace, string innerSpace, string urlParam, string tableKey, string tableName, string theField, string theWhere, string theOrder, int currentPage, SqlCommand cmdParam, params object[] objs)
{
int num = 0;
Hashtable ha = new Hashtable();

if (navNum % 2 == 0) navNum++;
if (firstPage == "0")
{
firstPage = "<font face=webdings>9</font>";
prevPage = "<font face=webdings>7</font>";
nextPage = "<font face=webdings>8</font>";
lastPage = "<font face=webdings>:</font>";
}
if (prevPage == "0")
{
firstPage = "";
prevPage = "<font face=webdings>7</font>";
nextPage = "<font face=webdings>8</font>";
lastPage = "";
}

SqlCommand cmd = cmdParam;
if (cmd == null) cmd = new SqlCommand();

try
{
cmd.Connection = new SqlConnection(ConnectionString);
cmd.CommandText = "select count(*) from " + tableName + " " + theWhere;
for (int i = 0; i < objs.Length; i += 2) cmd.Parameters.Add(objs[i].ToString(), objs[i + 1]);
cmd.Connection.Open();
num = Convert.ToInt32(cmd.ExecuteScalar());
}
catch (SqlException ex)
{
ErrorMessage = ex.Message;
}
finally
{
cmd.Connection.Close();
}

int total = (num - 1) / pageSize + 1;
if (currentPage < 1 || currentPage > num || num < 1) return null;
string sql = "select top " + pageSize + " " + theField + " from " + tableName + " " + theWhere + " " + theOrder;
if (currentPage != 1) sql = "select top " + pageSize + " " + theField + " from " + tableName + " " + theWhere + " and " + tableKey + " not in (select top " + pageSize * (currentPage - 1) + " " + tableKey + " from " + tableName + " " + theWhere + " " + theOrder + ") " + theOrder;
cmd.CommandText = sql;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);

string span = "<span>";
if (currentPage != 1)
{
span += "<a title='首页' href='" + urlParam + "&page=1'>" + firstPage + "</a>" + outerSpace;
span += "<a title='上一页' href='" + urlParam + "&page=" + (currentPage - 1) + "'>" + prevPage + "</a>" + outerSpace;
}
else
{
span += "<a disabled=disabled>" + firstPage + "</a>" + outerSpace;
span += "<a disabled=disabled>" + prevPage + "</a>" + outerSpace;
}
if (navNum > 0)
{
int start = 1, end = total, len = navNum / 2;
if (navNum < total)
{
start = currentPage - len;
end = currentPage + len;
if (start < 1)
{
start = 1;
end = navNum;
}
if (end > total)
{
start = total - navNum + 1;
end = total;
}
}
for (int i = start; i <= end; i++)
{
if (i == currentPage)
{
//span += "<font color=red>" + leftHtml + i + rightHtml + "</font>" + innerSpace;
span += i + innerSpace;
}
else
{
if (i != end)
{
span += "<a title='第" + i + "页' href='" + urlParam + "&page=" + i + "'>" + leftHtml + i + rightHtml + "</a>" + innerSpace;
}
else
{
span += "<a title='第" + i + "页' href='" + urlParam + "&page=" + i + "'>" + leftHtml + i + rightHtml + "</a>";
}
}
}
span = span.Trim(' ');
span += outerSpace;
}
if (currentPage != total)
{
span += "<a title='下一页' href='" + urlParam + "&page=" + (currentPage + 1) + "'>" + nextPage + "</a>" + outerSpace;
span += "<a title='尾页' href='" + urlParam + "&page=" + ((num - 1) / pageSize + 1) + "'>" + lastPage + "</a>";
}
else
{
span += "<a disabled=disabled>" + nextPage + "</a>" + outerSpace;
span += "<a disabled=disabled>" + lastPage + "</a>";
}
ha.Add("MainPage", span);
span = "<table cellpadding=0 cellspacing=0 width=100% style='margin-top:10px'><tr><td style='padding-left:10px;padding-top:2px'>第<font color=red>" + currentPage + "</font>页 共<font color=red>" + total + "</font>页 每页<font color=red>" + pageSize + "</font>条记录 共<font color=red>" + num + "</font>条记录</td><td align=right>" + span + "</td></tr></table>";
ha.Add("AutoPage", span);
span = "\n<input id=goto size=1 value=" + currentPage + " onchange=\"location.href='" + urlParam + "&page='+document.getElementById('goto').value\">\n<input type=button size=1 value=GO onclick=\"location.href='" + urlParam + "&page='+document.getElementById('goto').value\">";
ha.Add("GotoPage", span);
span = "\n<select onchange=\"location.href='" + urlParam + "&page='+this.value\">\n";
for (int i = 1; i <= total; i++) span += "\t<option value=" + i + (i == currentPage ? " selected" : "") + ">第" + i + "页</option>\n";
span += "</select>\n";
ha.Add("SelectPage", span);
ha.Add("CurrentPage", currentPage);
ha.Add("TotalPage", total);
ha.Add("PageSize", pageSize);
ha.Add("TotalRecords", num);
ha.Add("DataSet", ds);
return ha;
}

jiangzhe556 2008-12-05
  • 打赏
  • 举报
回复
http://download.csdn.net/source/711890
Tiger_ldy 2008-12-05
  • 打赏
  • 举报
回复
aspnetpager 是开源的 (推荐),你可以按你自己的要求改啊
flyso 2008-12-05
  • 打赏
  • 举报
回复
我的BLOG上很多,网址http://www.flyso.net
wuyq11 2008-12-05
  • 打赏
  • 举报
回复
aspnetpage控件可实现
加载更多回复(17)
本站采用 ACTCM 网站管理系统。 ACTCMS是一款具有强大的功能的基于ASP语言的开源内容管理软件,有UTF-8和GB2132两个编码版本,支持ACCESS和MSSQL两种数据库。ACTCMS是一款完全开源的程序,都毫无保留的完全开放源代码,用户不需额外安装其他DLL组件,其最大的特点是易用, ACTCMS.搭积木式的网站建设. 系统自带三大模型,系统模型,注册模型.表单模型.让你无顾虑制作属于自己的特色网站 国内目前为止ASPCMS中唯一支持注册模型的CMS 加入函数接口,如果对ASP熟悉一点的.您还可以自己编写函数.来和系统融合.直接调用系统函数 一、系统特色: 独特模型管理。通过模型管理,您可以基于文章系统克隆出不同的模型,使用标签 模板可扩展图片、新闻、文章、下载、Flash...等多个频道。每个模型可以自定义显示添加选项,更为强大的是,您还可以自定义字段管理,可以随时根据需要自己自定义添加、设立、调整需要添加的选项,这些选项可以是文本框、下拉框等,也可以是图片、文件、随机数等。每个模型都具有易用的信息添加系统,简短和完整标题设置、分页设置、TOP设置、热点设置、是否允许评论、关键字、导读、阅读权限等等……不需要您再去二次开发插件。 字段随心所欲控制 数据校验规则 作为搜索条件 数据唯一功能更为强大 强大标签管理。您只要将这些标签插入到页面需要的位置即可实现相应功能,而这一切不需要您去学ASP语言,因为这一切ACTCMS已经为您完成。系统拥有强大的标签自动生成系统,任何您想要实现的功能,例如输出格式(table和div可选)、排序方法、文章属性、文章行距、文章数量、标题字数、日期格式、分隔图片、标题样式等等只需要在后台进行相关设置即可;任何网站所有的输出功能,如栏目文章、图片文章、幻灯片、循环栏目、分页文章、相关文章、网站导航、友情链接等,也只需要在后台进行相关设置即可。同时可以通过自定义标签的使用,创立自己独特标签,来让整个网站更为完善。 新增代码模式,制作网站更方面.更简单 3、可选生成格式。整个网站可以快速地、全部生成静态页面,支持动态、纯静态、伪静态等多种格式发布,易于搜索引擎的快速收录,有效提升网站搜索提名,充分满足您的多样化需要,让您的网站立于不败之地。发布静态站点时可以选择不同的后缀生成名,可分别生成各频道、栏目、网站首页的静态文件,也可以自主设置添加文章时是否同时生成内容页、栏目页和首页。 4、特色会员系统。会员注册采用模型管理方式,您可以根据情况自定义添加不同的注册模型,如普通用户、企业用户等等,每个模型还可以自定义添加不同字段,如籍贯、头像、选项等。各个添加的用户组可以配置不同的权限和计费方式,如扣点数、有效期、无限期等。后台还配有充值卡添加管理功能和用户短信管理功能等。在会员操作前台,会员可以进行续费、交友、投稿等操作。会员管理系统还与流行论坛高度整合,让整个网站与网站论坛完美融合,让您的网站更具竞争力。 5、齐全文章管理。在信息添加管理系统那里,具备齐全的文章管理功能。文章管理、审核、评论管理、tags管理、回收站、栏目添加管理、生成操作等功能一应俱全。集成系统内置了世界著名的开源编辑器FckEditor的HTML在线编辑系统,可在后台选择默认、简洁、超简洁等模式,使编辑文章能所见所得,添加新闻时还可根据分页标签自动分页。 二、其他功能 1、在线系统设置。在系统设置里面可以方便设置站点基本信息、进行管理员管理、日志管理、插件管理、维护数据库等。 2、无限级栏目分类。系统支持无限级分类,添加、修改、删除,操作十分简单方便。 3、多样化的模板管理。页面模板可以在线预览、添加、修改、删除,每个模型、栏目可以绑定不同的模板,让您的网站不再陷入单一化的页面状态,只要您愿意,您的站点绝不可能和其他人的站点有雷同。 4、友情链接系统。可以新增友情链接类别,审核申请的链接,在后台可以统计链接点击次数等。 5、留言系统。对留言进行回复、删除管理。 6、管理员权限分配。管理员分栏目管理员、模型管理员、超级管理员三级,可以给予某个管理员某个栏目的管理、增加、修改、删除、审核中的任一或多个操作权限,将责任细化到每个管理员,再也不用为管理责任不清而烦劳。 7、强大的图片新闻幻灯显示系统,采用FLASH或者纯图片方式,将您的图片文章以融合、百叶窗等多种交替方面幻灯显示,让您的网站与大网站相媲美 8、强大的文章显示功能,文章除了分页、页数统计这些,还拥有上一篇、下一篇提示、点击数、评论留言、查看权限(收费文章)、投稿系统等强大的功能 9、独创的Tags标签,该功能随着系统使用时间的增加,一个真正属于您自己的词库也在慢慢建立。可根据您的需要调用热门Tags,同论坛精华贴一样,让用户快速找到最有用的信息 10、配套采集功能。系统与ET采集系统无缝整合,提供接口,您可以通过强大的ET采集器将文章采集到ACTCMS系统中。 11、超小的程序,仅有1M多点。虽然ACTCMS拥有这么多的强大的功能,可是它的体积很小,这显然十分有益于大幅度提高网站的访问速度,非常适宜新站长和空间较小的站长使用,更多功能还有待您去挖掘. 12、免费而强大的后续支持。首先,ACTCMS教程丰富。ACTCMS虽然易用,但考虑到新人站长们很多并没有接触过网站制作等,所以ACTCMS专门组建了视频教程制作小组,将整个ACTCMS网站构建流程制作出视频教程,只要会用鼠标、键盘就可以通过视频教程构建出属于自己的网站。 演示:http://www.xi7.net 广告设置在templets模板里面修改! 管理目录/admin/ 管理:bestcc 密码:xi7.net

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧