终于独立实现分页啦
? //前臺代碼:? //沒什么好說的; <table>
??????????? <tr>
??????????????? <td align="right" style="width: 480px">當前第
??????????????????? <asp:Label ID="LblNum" runat="server"></asp:Label>頁/共有
??????????????????? <asp:Label ID="LblPage" runat="server"></asp:Label>頁 |
??????????????????? <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="images/back.gif" ="ImageButton2_Click" />
??????????????????? <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/next.gif" ="ImageButton1_Click" /></td>
??????????? </tr>
??????? </table>
//后臺代碼: public partial class Newcenter_Notice_ManagementNotice : System.Web.UI.Page
{
??? public static int PageIndex = 1; //調用了CuctSoft.SqlDbHelper 類中的方法:
??? private CuctSoft.SqlDbHelper gxc = new CuctSoft.SqlDbHelper();
??
??? protected void Page_Load(object sender, EventArgs e)
??? {
??????? datalistbing(PageIndex, 10); //刪除功能:
??????? if (Request.QueryString["action"] == "del")
??????? {
??????????? gxc.dbExecuteSql("delete from Notice where NoticeID=" + Request.QueryString["id"] + "");
??????????? datalistbing(PageIndex, 10);
??????? } } //定義圖片按鈕適時顯現: public void datalistbing(int PageIndex,int PageSize)
??? { //調用了自己加的類——CuctSoft.Notice?:
??????? CuctSoft.Notice gxc = new CuctSoft.Notice();
??????? DataList1.DataSource = gxc.ShowPage(PageIndex, 10);
??????? DataList1.DataBind();
??????? int PageS = gxc.ShowPageCount();
??????? if (PageS > PageIndex) { ImageButton1.Visible = true; } else { ImageButton1.Visible = false; }
??????? if (PageIndex > 1) { ImageButton2.Visible = true; } else { ImageButton2.Visible = false; }
??????? LblNum.Text = Convert.ToString(PageIndex);
??????? LblPage.Text = Convert.ToString(PageS);
??? } //分頁的圖片按鈕:
??? protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
??? {
??????? PageIndex = PageIndex - 1;
??????? datalistbing(PageIndex, 10);
??? }
??? protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
??? {
??????? PageIndex = PageIndex + 1;
??????? datalistbing(PageIndex, 10);
??? }
}
??????????? <tr>
??????????????? <td align="right" style="width: 480px">當前第
??????????????????? <asp:Label ID="LblNum" runat="server"></asp:Label>頁/共有
??????????????????? <asp:Label ID="LblPage" runat="server"></asp:Label>頁 |
??????????????????? <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="images/back.gif" ="ImageButton2_Click" />
??????????????????? <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/next.gif" ="ImageButton1_Click" /></td>
??????????? </tr>
??????? </table>
//后臺代碼: public partial class Newcenter_Notice_ManagementNotice : System.Web.UI.Page
{
??? public static int PageIndex = 1; //調用了CuctSoft.SqlDbHelper 類中的方法:
??? private CuctSoft.SqlDbHelper gxc = new CuctSoft.SqlDbHelper();
??
??? protected void Page_Load(object sender, EventArgs e)
??? {
??????? datalistbing(PageIndex, 10); //刪除功能:
??????? if (Request.QueryString["action"] == "del")
??????? {
??????????? gxc.dbExecuteSql("delete from Notice where NoticeID=" + Request.QueryString["id"] + "");
??????????? datalistbing(PageIndex, 10);
??????? } } //定義圖片按鈕適時顯現: public void datalistbing(int PageIndex,int PageSize)
??? { //調用了自己加的類——CuctSoft.Notice?:
??????? CuctSoft.Notice gxc = new CuctSoft.Notice();
??????? DataList1.DataSource = gxc.ShowPage(PageIndex, 10);
??????? DataList1.DataBind();
??????? int PageS = gxc.ShowPageCount();
??????? if (PageS > PageIndex) { ImageButton1.Visible = true; } else { ImageButton1.Visible = false; }
??????? if (PageIndex > 1) { ImageButton2.Visible = true; } else { ImageButton2.Visible = false; }
??????? LblNum.Text = Convert.ToString(PageIndex);
??????? LblPage.Text = Convert.ToString(PageS);
??? } //分頁的圖片按鈕:
??? protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
??? {
??????? PageIndex = PageIndex - 1;
??????? datalistbing(PageIndex, 10);
??? }
??? protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
??? {
??????? PageIndex = PageIndex + 1;
??????? datalistbing(PageIndex, 10);
??? }
}
轉載于:https://www.cnblogs.com/gengxiaochao/archive/2007/09/03/879958.html
總結
- 上一篇: winpcap的程序(转)
- 下一篇: 使用prototype特性编程中的效率问