悬赏分:10 浏览:370 次
入行不深,很简单的思路做的:
自定义<pagetemplate>,里面有"上一页","下一页"等按扭
<asp:button CommandName="page" CommandArgument="prev" >...能正常使用.
数字分页号我是这么实现的:
在Gridview DataBound 事件里添加数字的<linkbutton>,然后在Gridview尾部添加这些控件,源代码如下:
protect void GridView2_DataBound(object sender , EventArgs e)
{
GridViewRow pagerow = GridView2.BottomPagerRow;
LinkButton[] mybutton = new LinkButton[GridView2.PageCount];
for (int i = 0; i < mybutton.Length; i++)
{
mybutton[i] = new LinkButton();
mybutton[i].Text = (i + 1).ToString();
mybutton[i].Click += new EventHandler(newsClass_Click);
mybutton[i].EnableViewState = true;
pagerow.Cells[0].Controls.Add(mybutton[i]);
}
}
问题是:当我按数字选择分页时能正常运行,但数字分页按扭就不见了。但按“上一页”,“下一页”能正常分页,也能显示数字分页按扭。。
请大家帮忙解决一下
|
4个月前 BesttimeBadtime : 谢谢两位,问题已解决了 原来是添加控件应放在RowCreate()事件里面就可以了 |