gridview控件上的自定义分页
下面的代码工作正常,如果我删除PagerSetting或删除PagerTemplate所以如果我同时( PagerSetting和PagerTemplate )然后我的页码不显示。
我的qeustion是:我如何在Gridview的底部显示(PagerTemplate和PagerSetting )? 请参阅以下源代码。
**** Page Size 15 25 50 100 1 Items Found
更新1:
我能够显示分页1 2 3 4 5 …但问题是:我不能同时拥有PagerSetting和PagerTemplate,如果我在gridview中同时拥有(PagerSetting和PagerTemplate)我的分页(1 2 3 4 5)不是显示,如果我删除PagerTemplate比我的分页显示(1 2 3 4 5 …)有意义吗?
更新:
这是我想要得到的:
<< >> 找到的总页数80 – 第1/80页 – PageSize {15,25,50,10}(这将是一个下拉列表)
你可以使用以下代码来做到这一点
-
后端代码(gridview的行创建事件):
protected void GridView_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Pager) { TableRow tr = (TableRow)e.Row.Cells[0].Controls[0].Controls[0]; if (tr.Cells[1] != null && (((tr.Cells[1]).Controls[0]) is LinkButton)) { LinkButton btnPrev = (LinkButton)(tr.Cells[1]).Controls[0]; if (btnPrev.Text == "...") { (((tr.Cells[1]).Controls[0]) as LinkButton).Text = "<"; } } if (tr.Cells[tr.Cells.Count - 2] != null && (((tr.Cells[tr.Cells.Count - 2]).Controls[0]) is LinkButton)) { LinkButton btnNext = (LinkButton)(tr.Cells[tr.Cells.Count - 2]).Controls[0]; if (btnNext.Text == "...") { (((tr.Cells[tr.Cells.Count - 2]).Controls[0]) as LinkButton).Text = ">"; } } }
}
-
并使用pagersetting作为:
你会得到你的输出。 ?
注意:不要忘记设置gridSize和AllowPaging =“true”的网格。
上述就是C#学习教程:gridview控件上的自定义分页分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/955297.html