gridview分页代码,c#gridview分页代码

2022-09-25   来源:实用知识

<asp:GridView ID="GridViewHistory" runat="server" AutoGenerateColumns="False"
CssClass="vip_table" GridLines="None" BorderStyle="None" CellPadding="0"
ShowHeader="False" AllowPaging="true" PageSize="20"
onpageindexchanging="GridViewHistory_PageIndexChanging">
<PagerTemplate>
<asp:LinkButton ID="lb_firstpage" runat="server" onclick="lb_firstpage_Click">首页</asp:LinkButton>
<asp:LinkButton ID="lb_previouspage" runat="server"
onclick="lb_previouspage_Click">上一页</asp:LinkButton>
<asp:LinkButton ID="lb_nextpage" runat="server" onclick="lb_nextpage_Click">下一页</asp:LinkButton>
<asp:LinkButton ID="lb_lastpage" runat="server" onclick="lb_lastpage_Click">尾页</asp:LinkButton>
第<asp:Label ID="lbl_nowpage" runat="server" Text="<%#GridViewHistory.PageIndex+1 %>" ForeColor="#db530f"></asp:Label>页/共<asp:Label
ID="lbl_totalpage" runat="server" Text="<%#GridViewHistory.PageCount %>" ForeColor="#db530f"></asp:Label>页
</PagerTemplate>


后台代码:

//分页
protected void GridViewHistory_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridViewHistory.PageIndex = e.NewPageIndex;
dataBinding();
}
protected void Button_search_Click(object sender, EventArgs e)
{
dataBinding();
}
protected void lb_firstpage_Click(object sender, EventArgs e)
{
this.GridViewHistory.PageIndex = 0;
dataBinding();
}
protected void lb_previouspage_Click(object sender, EventArgs e)
{
if (this.GridViewHistory.PageIndex > 0)
{
this.GridViewHistory.PageIndex--;
dataBinding();
}
}
protected void lb_nextpage_Click(object sender, EventArgs e)
{
if (this.GridViewHistory.PageIndex < this.GridViewHistory.PageCount)
{
this.GridViewHistory.PageIndex++;
dataBinding();
}
}
protected void lb_lastpage_Click(object sender, EventArgs e)
{
this.GridViewHistory.PageIndex = this.GridViewHistory.PageCount;
dataBinding();
}

dataBinding()为GridViewHistory的数据源绑定事件

gridview分页代码,c#gridview分页代码

http://m.tuzhexing.com/zhishi/1206412/

展开更多 50 %)
分享

热门关注

高考生填志愿实用知识范文(通用3篇)

实用知识

高二上册数学实用知识点(通用3篇)

实用知识

八年级语文上册实用知识点范文(精选三篇)

实用知识

初二物理上册实用知识点精选三篇

实用知识

消防安全实用知识心得体会【汇编三篇】

实用知识

买什么车最经济实惠,5款大空间实惠实用车型导购

实用知识

出乎意料地好用,索尼XPERIA,Z5,Premium一周体验

实用知识

中国涡轮风扇发动机的第一个成果—WS9秦岭发动机

实用知识

既不要三厢也不喜欢SUV,那你得看看全新高尔夫·嘉旅

实用知识

电磁炮是什么,中国超级电磁炮威力惊人,打穿10米混凝土

实用知识