谢谢各位大侠了,小弟用datalist进行分页出现了这个问题!        string theKind=Request.QueryString["ArticeKind"].ToString();
        SqlConnection theCon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString());
        SqlDataAdapter theAdapter = new SqlDataAdapter("SELECT * FROM artice WHERE kind='" + theKind + "'", theCon);
        DataSet theSet = new DataSet();        theCon.Open();
        theAdapter.Fill(theSet, "Page");
        PagedDataSource thePage = new PagedDataSource();
        thePage.DataSource = theSet.Tables["Page"].DefaultView;
        Record_total.Text = theSet.Tables["Page"].Rows.Count.ToString();
        thePage.AllowPaging = true;
        thePage.PageSize = 20;
        Page_total.Text = thePage.PageCount.ToString();_______________________________________________________________________________________________________________浏览的时候给出的错误信息如下:“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------对象名  'artice' 无效。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 对象名  'artice' 无效。源错误: 
行 21: 
行 22:         theCon.Open();
行 23:         theAdapter.Fill(theSet, "Page");
行 24:         PagedDataSource thePage = new PagedDataSource();
行 25:         thePage.DataSource = theSet.Tables["Page"].DefaultView;
 源文件: d:\School\Browse.aspx.cs    行: 23 

解决方案 »

  1.   

    调试一下,看artice是在哪里定义的,右键找到所有引用后,再一项项查看一下,只是个常见的小问题而已。
      

  2.   


     
     
    ASP.NET2.0中datalist仿百度分页 
    注意这个分页在1.0中无效 
    using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Collections; 
    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 MySql.Data.MySqlClient; 
    using System.Data.SqlClient; 
    using System.IO; 
    public partial class mysql : System.Web.UI.Page 

        SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["constrmy"]); 
        int ToatalCountRecord;//总记录数 
        int PageItem = 4;//每页显示的条数 
        int CurrentPage = 1;//当前页数 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            
            if (!this.Page.IsPostBack) 
            { 
                if (Request.QueryString["page"] != null) 
                { 
                    if (!Int32.TryParse(Request.QueryString["page"].ToString(), out CurrentPage)) 
                    { 
                        Response.Write("请输入分页参数!"); 
                        Response.End(); 
                        return; 
                    } 
                } 
                
                this.BuidGrid(); 
            } 
        } 
        
        private void BuidGrid() 
        { 
            string s2 = "select * from ts1"; 
            SqlDataAdapter da = new SqlDataAdapter(s2, conn); 
            DataSet ds = new DataSet(); 
            int startRecord = (CurrentPage - 1) * PageItem; 
            da.Fill(ds, startRecord, PageItem, "a"); 
            this.DataList1.DataSource = ds.Tables["a"].DefaultView; 
            this.DataList1.DataBind(); 
            SqlCommand comm = new SqlCommand("select count(*) from ts1", conn); 
            conn.Open(); 
            ToatalCountRecord = Convert.ToInt32(comm.ExecuteScalar()); 
            conn.Close(); 
            BuildPages(); 
        } 
        private void BuildPages() 
        { 
            int Step = 5;//偏移量 
            int LeftNum = 0;//做界限 
            int RightNum = 0;//右界限 
            string PageUrl = Request.FilePath; 
            int PageCount = (int)Math.Ceiling((double)(ToatalCountRecord) / PageItem); 
            if (CurrentPage - Step  < 1) 
            { 
                LeftNum = 1; 
            } 
            else 
            { 
                LeftNum = CurrentPage - Step; 
            } 
            if (CurrentPage + Step > PageCount) 
            { 
                RightNum = PageCount; 
            } 
            else 
            { 
                RightNum = CurrentPage + Step; 
            } 
            string OutPut = ""; 
            if (CurrentPage > 1) 
            { 
                OutPut += " <a href='" + PageUrl + "?page=" + (CurrentPage - 1) + "'>" + "上一页" + " </a>"; 
            } 
            for (int i = LeftNum; i  <= RightNum; i++) 
            { 
                if (i == CurrentPage) 
                { 
                    OutPut += " <font color=red>" + " " +"["+i.ToString() +"]"+ "" + " </font>"; 
                } 
                else 
                { 
                    OutPut += " <a href='" + PageUrl + "?page=" + i.ToString() + "'>" + " " +"["+ i.ToString() +"]"+ " " + " </a>"; 
                } 
            } 
            if (CurrentPage  < PageCount) 
            { 
                OutPut += " <a href='" + PageUrl + "?page=" + (CurrentPage + 1) + "'>" + "下一页" + " </a>"; 
            } 
            this.PageInfo.InnerHtml = OutPut; 
        } 
      

    请注意颜色标注部分 
    需要在前台添加一个  <div id="PageInfo" runat="server" >   
      

  3.   

    SELECT * FROM artice 
    表名写错了?
      

  4.   

    如果我没猜错,article你少写了一个字母l……
      

  5.   

    表名写错了,数据库里没有artice表