那个东西要自己写。。
我写了一个,挺复杂的。。。
给你做参考吧。。。。
<%
//分页
int allWriteBackForumNum = AllDataWorkTitle.WriteBackFroumNum(forumTitleId); //得到全部回帖数量,分页用
int maxPageNum = allWriteBackForumNum / 10 + 1;
if (allWriteBackForumNum % 10 == 0 && allWriteBackForumNum != 0) //如果回帖数量是10的倍数,减去最后那个空页
{
maxPageNum = maxPageNum - 1;
}
Response.Write(" ");//输出写空格
Response.Write("共" + (allWriteBackForumNum - 1).ToString() + "楼");
//输出页数并且都加上链接而且页数多的话,显示部分(花线内)
//************************************************************************************************************
Response.Write(" ");
if (allWriteBackForumNum != 0 && maxPageNum <= 10)
{
for (int j = 1; j <= maxPageNum; j++)
{
if (j == pageNum)
{
Response.Write(" [" + j.ToString() + "] ");
}
else
{
string ee = " + "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]";
Response.Write(" " + ee + " ");
}
}
Response.Write("
");
}
else if (maxPageNum > 10)
{
if (pageNum == 1)
{
for (int j = 1; j <= 10; j++)
{
if (j == pageNum)
{
Response.Write(" [" + j.ToString() + "] ");
}
else
{
string ee = " productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]";
Response.Write(" " + ee + " ");
}
}
string gg = " productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + (pageNum + 1).ToString() + ">>>";
string ff = " productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + maxPageNum + ">...." + maxPageNum.ToString() + "";
Response.Write(" " + gg + " " + ff + " ");
}
else if (pageNum == maxPageNum)
{
string ff = " productId + "&ForumTitleId=" + forumTitleId + "&pageNum=1>1....";
string gg = " productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + (pageNum - 1).ToString() + "><<";
Response.Write(" " + ff + " " + gg + " ");
for (int j = maxPageNum - 9; j <= maxPageNum; j++)
{
if (j == pageNum)
{
Response.Write(" [" + j.ToString() + "] ");
}
else
{
string ee = " + "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]";
Response.Write(" " + ee + " ");
}
}
}
else
{
string ff = " productId + "&ForumTitleId=" + forumTitleId + "&pageNum=1>1....";
string gg = " productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + (pageNum - 1).ToString() + "><<";
Response.Write(" " + ff + " " + gg + " ");
if (pageNum - 1 > 5 && maxPageNum - pageNum > 5)
{
for (int j = pageNum - 4; j <= pageNum + 6; j++)
{
if (j == pageNum)
{
Response.Write(" [" + j.ToString() + "] ");
}
else
{
string ee = " + "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]";
Response.Write(" " + ee + " ");
}
}
}
else if (pageNum - 1 <= 5)
{
for (int j = 1; j <= 10; j++)
{
if (j == pageNum)
{
Response.Write(" [" + j.ToString() + "] ");
}
else
{
string ee = " brandId + "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" +
j.ToString() + "]";
Response.Write(" " + ee + " ");
}
}
}
else
{
for (int j = maxPageNum - 10; j <= maxPageNum; j++)
{
if (j == pageNum)
{
Response.Write(" [" + j.ToString() + "] ");
}
else
{
string ee = " brandId + "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]";
Response.Write(" " + ee + " ");
}
}
}
string hh = " productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + (pageNum + 1).ToString() + ">>>";
string rr = " productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + maxPageNum + ">...." + maxPageNum.ToString() + "";
Response.Write(" " + hh + " " + rr + " ");
}
}
//************************************************************************************************************
//输出页数并且都加上链接而且页数多的话,显示部分(花线内)
%>
写那么多有什么用 分页吗 给你个分页的sql语句 不就行了
select top 20 * from userposts where(titleid not in (select top 10 titleid from userposts))
上面的意思就是 取出20条内容 从第10条开始 也就是11-30条的内容
你绑定数据的时候 传sql语句 就传这个 到时候 可以 count(*) 查出所有的行数 然后吧 top20 和 后面的 top10 写成变量 分页的时候传进去2个变量
然后执行sql语句 数据结果绑定到控件 然后显示 想怎么分就怎么分了
如果数据量少就用 gridview 自带的分页 方便(自带的分页是一次吧所有的数据都加载到内存中) 如果数据多就算了 只能用上面的sql语句了
LZ好,#include
#include
void main()
{
float a,b,c,p,s; //这里用double比较好
printf("Input a,b,c:\n");
scanf("%f%f%f",&a,&b,&c); //scanf把三个double型的变量输送到a,b,c的地址,故用取地址符&
//以下代码帮你重新写过,因为你写的比较乱。。。
if(a>0.0 && b>0.0 && c>0.0 && fabs(a-b) < c && fabs(b-c) < a && fabs(a-c) {
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("The result is %f\n",s);
}
else
printf("Data error!\n");
} 6477希望对你有帮助!
这个是通过数据库实现在的,写一个分页存储过程。之后,把每次你要显示的数据段给数据库就可以了。
分页存储过程;
create procedure sp_GetCurentPage
(@pagesize int, --页面的大小
@pageindex int) --当然的页号
as
begin
with temptbl as (
SELECT ROW_NUMBER() OVER (ORDER BY address desc)AS Row, * from test )
SELECT * FROM temptbl where Row between
(@pageindex-1)*@pagesize+1 and (@pageindex-1)*@pagesize+@pagesize
end
这样在你的按钮事件里,每次就是重新绑定一下数据显示就可以了。
GridView本身就有分页功能,将AllowPaging设置成True就可以了。
或者你自己写一个DataSet用DataAdapter去Fill这个DataSet,再将DataSet绑定到GridView。
int currentIndex = 0;
int pageSize = 5;
string orderSQL = "SELECT * FROM Orders ORDER BY OrderID";
// Assumes that connection is a valid SqlConnection object.
SqlDataAdapter adapter = new SqlDataAdapter(orderSQL, connection);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, currentIndex, pageSize, "Orders");