日期:2014-05-19  浏览次数:20806 次

GridView控件分页出错了! 如何实现分页功能?
执行分页后出现   错误如下:
IListSource   不包含任何数据源。  
说明:   执行当前   Web   请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。  

异常详细信息:   System.Web.HttpException:   IListSource   不包含任何数据源。


看我的代码,页面初始化部份我将邦定放在了NOT   ISPOSTBACK   中,如果将邦定放到NOT   ISPOSTBACK   外   就正确。    


protected   void   Page_Load(object   sender,   EventArgs   e)
        Conn1   =   new   SqlConnection(myclass.setconn());
                Conn2   =   new   SqlConnection(myclass.setconn());
                string         sqlstr   =   "select   BH,XMMC,XMBH,DWMC,TZLY,SBSJ   from   LXSBB   ";
                string   wheres1= " ",wheres= " ";

                wheres   =   "   WHERE   (JD=0)AND(ZT= '0 ')AND(DWMC   LIKE   '%{0}% ') ";
                wheres   =   string.Format(wheres,   Session[ "DSMC "].ToString());

                if   (TextBox1.Text.Trim()!= " ")  
                {
                        switch(DropDownList1.SelectedValue)
                        {
                                case   "项目名称 "   :     wheres1= "AND(XMMC   LIKE   '%{0}% ')   ";
                                        break   ;
                                case   "项目编号 "   :     wheres1= "AND(XMBH   LIKE   '%{0}% ')   ";
                                        break   ;
                                case   "投资来源 ":     wheres1   = "AND(TZLY   LIKE   '%{0}% ')   ";
                                        break   ;
                        }
                }
                if   (wheres1!= " ")
                {                        
                          wheres1=string.Format &n