日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

GridView的翻页

發(fā)布時(shí)間:2025/4/16 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 GridView的翻页 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
網(wǎng)上找的資料
屬性
AllowPaging="True" PageSize="15"
前臺

<PagerTemplate>
????
<table?width="100%"?style="font-size:12px;">
????????
<tr>
????????
<td?style="text-align:?right">
????????????第
<asp:Label?ID="lblPageIndex"?runat="server"?Text='<%#?((GridView)Container.Parent.Parent).PageIndex?+?1?%>'></asp:Label>
????????????/共
<asp:Label?ID="lblPageCount"?runat="server"?Text='<%#?((GridView)Container.Parent.Parent).PageCount?%>'></asp:Label>&nbsp;&nbsp;
????????????
<asp:LinkButton?ID="btnFirst"?runat="server"?CausesValidation="False"
????????????????CommandName
="Page"?Text="首頁"?CommandArgument="first"?OnClick="btnFirst_Click">
????????????
</asp:LinkButton>
????????????
<asp:LinkButton?ID="btnPrev"?runat="server"?CausesValidation="False"
????????????????CommandName
="Page"?Text="上一頁"?CommandArgument="prev"?onclick="btnFirst_Click">
????????????
</asp:LinkButton>
????????????
<asp:LinkButton?ID="btnNext"?runat="server"?CausesValidation="False"
????????????????CommandName
="Page"?Text="下一頁"?CommandArgument="next"?OnClick="btnFirst_Click">
????????????
</asp:LinkButton>
????????????
<asp:LinkButton?ID="btnLast"?runat="server"?CausesValidation="False"
????????????????CommandName
="Page"?Text="尾頁"?CommandArgument="last"?OnClick="btnFirst_Click">
????????????
</asp:LinkButton>
????????????
<asp:TextBox?ID="txtNewPageIndex"?runat="server"?Text='<%#?((GridView)Container.Parent.Parent).PageIndex?+?1?%>'
????????????????Width="20px"?AutoPostBack="True"?
????????????????ontextchanged="txtNewPageIndex_TextChanged">
</asp:TextBox>
????????????
<asp:LinkButton?ID="btnGo"?runat="server"?CausesValidation="False"?CommandArgument="go"
????????????????CommandName
="Page"?Text="GO"?OnClick="btnFirst_Click"></asp:LinkButton>
????????
</td>
????????
</tr>
????
</table>
</PagerTemplate>

后臺
protected?void?btnFirst_Click(object?sender,?EventArgs?e)
????????{
????????????
try
????????????{
????????????????
switch?(((LinkButton)sender).CommandArgument.ToString())
????????????????{
????????????????????
case?"first":
????????????????????????gdvck.PageIndex?
=?0;
????????????????????????
break;
????????????????????
case?"last":
????????????????????????gdvck.PageIndex?
=?gdvck.PageCount?-?1;
????????????????????????
break;
????????????????????
case?"prev":
????????????????????????gdvck.PageIndex?
=?gdvck.PageIndex?-?1;
????????????????????????
break;
????????????????????
case?"next":
????????????????????????gdvck.PageIndex?
=?gdvck.PageIndex?+?1;
????????????????????????
break;
????????????????????
case?"go":
????????????????????????{
????????????????????????????GridViewRow?gvr?
=?gdvck.BottomPagerRow;
????????????????????????????TextBox?temp?
=?(TextBox)gvr.FindControl("txtNewPageIndex");
????????????????????????????
int?res?=?Convert.ToInt32(temp.Text.ToString());
????????????????????????????gdvck.PageIndex?
=?res?-?1;
????????????????????????}
????????????????????????
break;
????????????????}
????????????????ImageButton1_Click(
null,?null);??//重綁
????????????}
????????????
catch?(Exception?ex)
????????????{
????????????????lblmessage.Text?
=?"請輸入1-9999自然數(shù)?-"?+?ex.Message.ToString();
????????????}
????????}

????????
protected?void?txtNewPageIndex_TextChanged(object?sender,?EventArgs?e)
????????{
????????????
try
????????????{
????????????????GridViewRow?gvr?
=?gdvck.BottomPagerRow;
????????????????TextBox?temp?
=?(TextBox)gvr.FindControl("txtNewPageIndex");
????????????????
int?res?=?Convert.ToInt32(temp.Text.ToString());
????????????????gdvck.PageIndex?
=?res?-?1;
????????????????ImageButton1_Click(
null,?null);
????????????}
????????????
catch?(Exception?ex)
????????????{
????????????????lblmessage.Text?
=?"請輸入1-9999自然數(shù)?-"?+?ex.Message.ToString();
????????????}
????????}


轉(zhuǎn)載于:https://www.cnblogs.com/mayingchao/archive/2009/08/14/1545814.html

總結(jié)

以上是生活随笔為你收集整理的GridView的翻页的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。