//前台代码: 
//没什么好说的;
<table>
            <tr>
                <td align="right" style="width: 480px">当前第
                    <asp:Label ID="LblNum" runat="server"></asp:Label>页/共有
                    <asp:Label ID="LblPage" runat="server"></asp:Label>页&nbsp;&nbsp;|&nbsp;
                    <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);
    }
}
posted on 2007-09-03 11:44  超少  阅读(254)  评论(1编辑  收藏  举报