LinkButton组这样用是不是正确的
我在做datalist分页功能,当我点击任一linkbutton时,是否会触发PagerButtonClick()。我自己有试了一下,好像没有触发该函数,是不是我代码有问题,是的话,应该怎么改,才能让按钮和PagerButtonClick()关联起来
public void PagerButtonClick(object sender, EventArgs e) { int curpage; curpage = Convert.ToInt32(Session["curpage"]); string arg = ((LinkButton)sender).CommandArgument.ToString(); switch (arg) { case "next":...; break; case "prev":...; break; case "last":...; break; default: ...; break; } }
...<tr> <asp:LinkButton ID="lb1" runat="server" CommandArgument="fir" >首页</asp:LinkButton> <asp:LinkButton ID="lb2" runat="server" CommandArgument="prev">上一页</asp:LinkButton> <asp:LinkButton ID="lb3" runat="server" CommandArgument="next">下一页</asp:LinkButton> <asp:LinkButton ID="lb4" runat="server" CommandArgument="last">末页</asp:LinkButton></tr>...
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandSource is LinkButton) { string arg = e.CommandArgument.ToString(); } }
[解决办法]
你自己写分页代码啊?
怎么不用分页控件呢?