我学access数据,初学ObjectDataSource分页!!startrowindexparamert和maxmunrowsparamert参数设置如下
 public static OleDbDataReader GetUser(int rowIndex, int recordCount)
    {
        conn = ControlData.Connstring();
        string selectString = "select Uid,Name,Password,Rname,RoleId from [User] inner join [Role] on Role.Rid=User.RoleId";
        cmd = new OleDbCommand(selectString, conn);
        conn.Open();
        DataReader = cmd.ExecuteReader();
        return DataReader;
        DataReader.Close();
        DataReader.Dispose();
    }
!!但不知在类方法如何加入上面参数??试过改为
public static OleDbDataReader GetUser(int rowIndex, int recordCount)
    {
       
//===================================================
        //conn = ControlData.Connstring();
        //string selectString = "select top @recordCount * from [User] inner join [Role] on Role.Rid=User.RoleId where Uid not in (select top (@rowIndex*recordCount) Uid from [User] order by id desc) order by id desc";        //OleDbParameter spRowIndex = new OleDbParameter("@rowIndex",OleDbType.Integer, 4);
        //spRowIndex.Direction = ParameterDirection.Input;
        //OleDbParameter spRecordCount = new OleDbParameter("@recordCount", OleDbType.Integer, 4);
        //spRecordCount.Direction = ParameterDirection.Input;        //spRowIndex.Value = rowIndex;
        //spRecordCount.Value = recordCount;        //cmd.Parameters.Add(spRowIndex);
        //cmd.Parameters.Add(spRecordCount);
              //cmd = new OleDbCommand(selectString, conn);
        //conn.Open();
        //DataReader = cmd.ExecuteReader();
        //return DataReader;
        //DataReader.Close();
        //DataReader.Dispose();
    }
 //cmd.Parameters.Add(spRowIndex);
  //cmd.Parameters.Add(spRecordCount);没有初始化的错误提示信息??
但不对啊????????

解决方案 »

  1.   

    access和ObjectDataSource有什么关系,好像ObjectDataSource是绑定对象的吧,不是数据库
      

  2.   

    If Request.QueryString("Btid") Is Nothing Or Request.QueryString("Btid") = "" Then
                Response.Write("<script>alert('页面参数出错!');location.href='../default.aspx'></script>")
            Else
                Tid = Int(Request.QueryString("Btid").ToString)            Dim Pgds As PagedDataSource = New PagedDataSource
                Pgds.DataSource = CreatDataSource(Tid).DefaultView
                Pgds.AllowPaging = True
                Pgds.PageSize = 5
                lblTotalPage.Text = Pgds.PageCount.ToString()
                Dim CurrentPage As Integer
                If Not Request.QueryString("Page") Is Nothing Then
                    CurrentPage = Convert.ToInt32(Request.QueryString("Page"))
                Else
                    CurrentPage = 1
                End If            Pgds.CurrentPageIndex = CurrentPage - 1
                lblCurrentPage.Text = CurrentPage.ToString()            If Not Pgds.IsFirstPage Then
                    lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurrentPage - 1) + "&Btid=" + Tid.ToString
                Else
                    Me.lnkPrev.Enabled = False
                End If            If Not Pgds.IsLastPage Then
                    lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurrentPage + 1) + "&Btid=" + Tid.ToString
                Else
                    Me.lnkNext.Enabled = False
                End If            rep_prdt.DataSource = Pgds
                rep_prdt.DataBind()        End If
      

  3.   

    Public Function CreatDataSource(ByVal Tid As String) As DataTable
            Return Prd.GetProductInfoByBigType(Tid)
        End Function
    ------------------------------------------------
    以前用VB。NET写的,不知道对你有没帮助
      

  4.   

    是数据源控件!默认分页大差了!所以想自定义分页!!自定义分页要设置startrowindexparamert和maxmunrowsparamert参数,和selecMod方法!在selectmod方法不知如何传参啊!