下面是Message.aspx
<table cellpadding="0" cellspacing="0">
        <tr>
            <td style="width: 100px">
            </td>
            <td style="width: 750px" valign="top">
                <aspataList ID="nb_dl" runat="server">
                    <ItemTemplate>
                        <table cellpadding="0" cellspacing="0" style="width: 737px; border-right: #999999 1px solid; border-top: #999999 1px solid; border-left: #999999 1px solid; border-bottom: #999999 1px solid;">
                            <tr>
                                <td style="width: 550px; background-color: #CCCCCC;">
                                    <aspabel ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container,"dataitem.user_name") %>' Font-Bold="True" ForeColor="MidnightBlue"></aspabel></td>
                                <td style="width: 200px; background-color: #CCCCCC; text-align: left;">
                                    留言时间:<aspabel ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container,"dataitem.addtime") %>'></aspabel></td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <aspabel ID="Label3" runat="server" Text='<%# DataBinder.Eval(Container,"dataitem.book_content") %>'></asp:Label><br />
                                    <font color="#999999">——————————————————</font></td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    回复:<asp:Label ID="Label4" runat="server" Text='<%# DataBinder.Eval(Container,"dataitem.book_reply") %>'></asp:Label></td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </aspataList>
                <center>
    <table style="width:343px;">
                <tr>
                    <td colspan="2"><asp:Label ID="Label1" runat="server" Text="当前页:"></asp:Label>【<asp:Label ID="curPage" runat="server" Text="1"></asp:Label>】</td>
                    <td colspan="2"><asp:Label ID="Label2" runat="server" Text="共有"></asp:Label>【<asp:Label ID="totalPage" runat="server"  ></asp:Label>】<asp:Label ID="Label3" runat="server" Text="页" Width="1px"></asp:Label></td>
                    <td><asp:LinkButton ID="firstPage" runat="server" Text="首页"  Font-Underline="false"></asp:LinkButton></td>
                    <td><asp:LinkButton ID="frontPage" runat="server" Text="上一页"  Font-Underline="false"></asp:LinkButton></td>
                    <td><asp:LinkButton ID="nextPage" runat="server" Text="下一页"  Font-Underline="false"></asp:LinkButton></td>
                    <td><asp:LinkButton ID="lastPage" runat="server" Text="尾页"  Font-Underline="false"></asp:LinkButton></td>
                </tr>
            </table></center>
                </td>
            <td style="width: 100px">
            </td>
        </tr>
        <tr>
            <td style="width: 100px">
            </td>
            <td style="width: 750px"><hr color="#191970" />
            </td>
            <td style="width: 100px">
            </td>
        </tr>
        <tr>
            <td style="width: 100px">
            </td>
            <td style="width: 750px"></td>
            <td style="width: 100px">
            </td>
        </tr>
    </table>
下面是Message.aspx.cs
  protected void Page_Load(object sender, EventArgs e)
    {
        show_bind();
    }
protected void show_bind()
    {
        db da = new db();
        int currpage = Convert.ToInt32(this.curPage.Text);
        PagedDataSource pds = new PagedDataSource();
        string strcmd = "select * from netbook order by addtime desc";
        DataSet ds = da.DS1(strcmd, "book");
        pds.DataSource = ds.Tables["book"].DefaultView;
        pds.AllowPaging = true;//是否允许分页
        pds.PageSize = 5;//每页显示数量
        pds.CurrentPageIndex = currpage - 1;//获取当前页的页码
        this.firstPage.Enabled = true;
        this.frontPage.Enabled = true;
        this.nextPage.Enabled = true;
        this.lastPage.Enabled = true;
        if (currpage == 1)
        {
            //不显示首页和上一页
            this.firstPage.Enabled = false;
            this.frontPage.Enabled = false;
        }
        if (currpage == pds.PageCount)
        {
            //不显示尾页和下一页
            this.nextPage.Enabled = false;
            this.lastPage.Enabled = false;
        }
        //绑定datalist控件
        this.totalPage.Text = Convert.ToString(pds.PageCount);
        this.nb_dl.DataSource = pds;
        this.nb_dl.DataBind();
    }
    protected void firstPage_Click(object sender, EventArgs e)//第一页
    {
        this.curPage.Text = "1";//curPage.Text为当前页
        this.show_bind();
    }
    protected void frontPage_Click(object sender, EventArgs e)//上一页
    {
        this.curPage.Text = Convert.ToString(Convert.ToInt32(this.curPage.Text) - 1);
        this.show_bind();
    }
    protected void nextPage_Click(object sender, EventArgs e)//下一页
    {
        this.curPage.Text = Convert.ToString(Convert.ToInt32(this.curPage.Text) + 1);
        this.show_bind();
    }
    protected void lastPage_Click(object sender, EventArgs e)//尾页
    {
        this.curPage.Text = this.totalPage.Text;//totalPage.Text为总页数
        this.show_bind();
    }下面的是db.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;/// <summary>
/// db 的摘要说明
/// </summary>
public class db
{
    private OleDbConnection oleconn;//声明一个OleDbConnection对象
    private OleDbCommand olecomm;//声明一个OleDbcommand对象
    private OleDbDataAdapter oleda;//声明一个OleDbDataAdapater对象
        public db()
        {
        oleconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + System.Web.HttpContext.Current.Server.MapPath("~/App_Data/zsj_table.mdb"));
        oleconn.Open();
    }
    public bool exceole(string olecmd)//用该方法来执行sql语句
    {
        olecomm = new OleDbCommand(olecmd, oleconn);
        try
        {
            olecomm.ExecuteNonQuery();
            return true;
        }
        catch (Exception e)
        {
            throw (new Exception(e.Message));
            return false;
        }
        finally
        {
            oleconn.Close();
        }
    }
    //返回一个dataset类型数据
    public DataSet DS(string strcom)
    {
        try
        {
            olecomm = new OleDbCommand(strcom, oleconn);
            oleda = new OleDbDataAdapter();
            oleda.SelectCommand = olecomm;
            DataSet ds = new DataSet();
            oleda.Fill(ds);
            return ds;
        }
        finally
        {
            oleconn.Close();
        }
    }
    public DataSet DS1(string strcom, string tablename)
    {
        try
        {
            OleDbDataAdapter oleda = new OleDbDataAdapter(strcom, oleconn);
            DataSet ds = new DataSet();
            oleda.Fill(ds, tablename);
            return ds;
        }
        finally
        {
            oleconn.Close();
        }
    }
    //返回一个OleDbdatareader类型数据    public OleDbDataReader oledr(string strcom)
    {
        olecomm = new OleDbCommand(strcom, oleconn);
        OleDbDataReader sdr = olecomm.ExecuteReader();
        return sdr;
        oleconn.Close();
    }
}
以上就是全部的代码,可是我实在是找不出来为什么老是出现“索引 -5 不是为负数,就是大于行数”。请各位高手帮忙解决下,谢谢了先!!!