本文介绍了添加链接按钮在ASP.NET中的GridView的页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何做到这一点?基本上,旁边的页码在GridView我想一个链接按钮禁用分页。这工作,但我想在GridView的页脚里面的按钮,旁边的页码。我该怎么做呢?
How do I do this? Basically, next to the page numbers in the GridView I want a link button to disable paging. This works, but I want the button inside the footer of the GridView, next to the page numbers. How do I do this?
推荐答案
您可以添加以下到codebehind(假设VB.Net是确定):
you could add following to your codebehind(assuming VB.Net is ok):
Private Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
Select Case e.Row.RowType
Case DataControlRowType.Footer
Dim LnkBtnPaging As New LinkButton
LnkBtnPaging.ID = "LnkBtnPaging"
LnkBtnPaging.Text = IIf(GridView1.AllowPaging, "no paging", "paging").ToString
AddHandler LnkBtnPaging.Click, AddressOf LnkBtnPagingClicked
e.Row.Cells(0).Controls.Add(LnkBtnPaging)
e.Row.Cells(0).ColumnSpan = e.Row.Cells.Count
While e.Row.Cells.Count > 1
e.Row.Cells.RemoveAt(e.Row.Cells.Count - 1)
End While
End Select
End Sub
Private Sub LnkBtnPagingClicked(ByVal sender As Object, ByVal e As EventArgs)
Me.GridView1.AllowPaging = Not Me.GridView1.AllowPaging
End Sub
记住网格的ID改成你的,并在GridView的的ASPX标记添加 ShowFooter =真
。
编辑:加code自动调整页脚的列数和columnspan
added code to auto-adjust footer's columncount and columnspan
这篇关于添加链接按钮在ASP.NET中的GridView的页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!