使用LinkButton实现DataList的分页问题,采用了
<asp:LinkButton id="lbnPrevPage" Text="上一页" CommandName="pre" OnCommand="_OnClick" runat="server" />
<asp:LinkButton id="lbnNextPage" Text="下一页" CommandName="next" OnCommand="_OnClick" runat="server" />
int CurrentPage=0;
public void _OnClick(Object sender, CommandEventArgs e)
{
Response.Write(CurrentPage+"");
switch (e.CommandName)
{
case "next":
if (CurrentPage < (PageCount - 1)) CurrentPage = CurrentPage+1;
break;
case "pre":
if (CurrentPage > 0) CurrentPage-=1;
break;
}
}
发现第一次点击LinkList的时候执行了_OnClick事件 ,后来点击就不管用?为什么?
你调试一下看看,那个CurrentPage的值是多少?