给DataGrid分页时“首页”、“上页”等导航如果使用链接的话该这么做?

quakecs 2003-08-21 01:02:38
现在我的DataGrid的“首页”、“上页”等分页导航是使用LinkButton,
如果将LinkButton改成链接的话,
程序应该怎么写?
...全文
39 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
nnh 2003-09-03
  • 打赏
  • 举报
回复
這是鏈接:
<asp:Linkbutton id="firsts" runat="server" CommandName="firsts" OnCommand="OnClick" text="第一頁" />
<asp:Linkbutton id="lbnprevpage" runat="server" CommandName="prev" OnCommand="OnClick" text="上一頁" />
<asp:Linkbutton id="lbnnextpage" runat="server" CommandName="next" OnCommand="OnClick" text="下一頁" />
<asp:Linkbutton id="lasts" runat="server" CommandName="lasts" OnCommand="OnClick" text="最后頁" />

處理的代碼:
Sub OnClick(obj As object,e As commandeventargs) '¤À­¶ªº¥N½X
Dim cmd As string=e.commandname
Select Case cmd
Case "next"
If Mydatagrid.currentpageindex<Mydatagrid.pagecount-1 Then
Mydatagrid.currentpageindex=Mydatagrid.currentpageindex+1
end if
Case "prev"
If Mydatagrid.currentpageindex>0 Then
Mydatagrid.currentpageindex=Mydatagrid.currentpageindex-1
end if
case "firsts"
Mydatagrid.currentpageindex=0
case "lasts"
Mydatagrid.currentpageindex = Mydatagrid.PageCount-1
End Select
Mydatagrid_DataBind()
End Sub
gOODiDEA 2003-09-03
  • 打赏
  • 举报
回复
//CurrentFile为当前文件名

if (ListDataGrid.CurrentPageIndex == 0)
{
PageLink.Text="[首页] [上一页] ";
}
else
{
PageLink.Text="[<a href='"+ CurrentFile +"?id=0&Page=1&SearchTitle="+SearchTitle+"&SearchKsid="+SearchKsid+"'>首页</a>] [<a href='"+ CurrentFile +"?id=0&Page="+(ListDataGrid.CurrentPageIndex)+"&SearchTitle="+SearchTitle+"&SearchKsid="+SearchKsid+"'>上一页</a>] ";
}
if (ListDataGrid.CurrentPageIndex == ListDataGrid.PageCount-1)
{

PageLink.Text=PageLink.Text+"[下一页] [尾页] ";
}
else
{
PageLink.Text=PageLink.Text+"[<a href='"+ CurrentFile +"?id=0&Page="+(ListDataGrid.CurrentPageIndex+2)+"&SearchTitle="+SearchTitle+"&SearchKsid="+SearchKsid+"'>下一页</a>] [<a href='"+ CurrentFile +"?id=0&Page="+ListDataGrid.PageCount+"&SearchTitle="+SearchTitle+"&SearchKsid="+SearchKsid+"'>尾页</a>] ";
}

在Page_load里
if ( !IsPostBack )
{
string cPage = "1";
if( Request.Params["Page"] != null )
{
cPage = Request.Params["Page"];
ListDataGrid.CurrentPageIndex = int.Parse( cPage ) - 1;
}
//绑定DATAGRID

}
xrll 2003-09-02
  • 打赏
  • 举报
回复
用webdiyer写的控件吧,有源码,不过要使用的话,分数要给他:
http://webdiyer.europe.webmatrixhosting.net/
ayine 2003-09-02
  • 打赏
  • 举报
回复
用DataGrid做导航???????????
听错了吧!!!!!!!!!
SuperZZZ 2003-09-02
  • 打赏
  • 举报
回复
我也想知道,找了很久了
知道了告诉我一声

62,025

社区成员

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

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

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

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