我建立了一个搜索查询的类QUERY.CS
现在想把窗体中的一个分页控件 
protected Wuqi.Webdiyer.AspNetPager pager 引用到此类中来
请问该怎么做啊
最好给出代码

解决方案 »

  1.   

    编辑AspNetPaper.Designer.cs,设置控件为public,然后直接.操作
      

  2.   

    出现 未将对象引用设置到对象的实例了
    我用的是using System.Web.UI.WebControls;
      

  3.   

    using System;
    using System.Data.SqlClient;
    using System.Data;
    using System.Web.UI.WebControls;namespace haiyunet
    {
    /// <summary>
    /// Query 的摘要说明。
    /// </summary>
    public class Query
    {
    public Query()
    {
    //
    // TODO: 在此处添加构造函数逻辑

    // }
    public Wuqi.Webdiyer.AspNetPager pager;
    private SqlDataAdapter da = null;
    public static string ConnString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
    public static SqlConnection conn = new SqlConnection(ConnString); private void connstr()

    if(conn.State==ConnectionState.Closed)
    {
    conn.Open();
    }
    } public DataTable BindPageData(string szSQL,string szTableName,string m_szIndex)  
    {

    connstr(); if(m_szIndex=="1")
    {
     SqlCommand cmd = new SqlCommand("select count(*)  from "+ szTableName +" where Name like '%" + szSQL +"%'",conn);
     int i=(int)cmd.ExecuteScalar(); 
     pager.RecordCount = i;
    da=new SqlDataAdapter("select *  from "+ szTableName +" where Name like '%" + szSQL +"%'",conn);
        }
    else if(m_szIndex=="2")
    {
    da=new SqlDataAdapter("select * from "+ szTableName +" where NewsTitle like '%" + szSQL +"%'",conn);
    }
    else
    {
    da=new SqlDataAdapter("select * from "+ szTableName +" where NewsTitle like '%" + szSQL +"%'",conn);
    }
    System.Data.DataSet ds = new DataSet();
    da.Fill(ds,pager.PageSize * (pager.CurrentPageIndex - 1), pager.PageSize, szTableName);
    DataTable dt = ds.Tables[szTableName];
    return dt;
    }
    }
    }
    贴出代码,请高人们分析,在pager.recordcount=i处错误