使用PagedDataSource对datalist进行分页,但是代码有错误。提示未将对象引用设置到对象的实例。
后台代码如下:
 protected void DataListBind(String str)
    {
        s = new PagedDataSource();        String connstr1 = "Data Source=FSPC;User ID=liubing;Unicode=True;password=aaa";
        OracleConnection conn = new OracleConnection(connstr1);
        OracleDataAdapter da = new OracleDataAdapter(str, conn);
        DataSet ds = new DataSet();
        da.Fill(ds);
        this.DataList_cxj.DataKeyField = "CXJ_ID";
        s.DataSource = ds.Tables["TB_CXJ_INFO"].DefaultView;//这句话有问题??
        s.AllowPaging = true;
        s.PageSize = 3;
        this.DataList_cxj.DataSource = s;
        this.DataList_cxj.DataBind();
        this.Label17.Text = "当前是第" + (s.CurrentPageIndex + 1) + "页。共" + s.PageCount + "页。";
    }