解决方案 »

  1.   

    private void BindView()
        {
            string begin = this.txt_beginTime.Value;
            string end = this.txt_endTime.Value;
            string comname = this.txtcomname.Text;
            MacAddrHaving mac = new MacAddrHaving();
            List<M_N_ComMun> list = mah.GetM_ComMun(comname);
            DataSet ds = new DataSet();
            foreach (M_N_ComMun cm in list)
            {
                comname = cm.ComName;
                DataSet ds1 = mac.GetOrderComNameList(comname, begin, end);
                if (null != ds1 && ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                    {
                        ds.Tables[0].Rows.Add(ds1.Tables[0].Rows[i]);
                    }
                }            
            }
            this.gv_Groups.DataSource = ds;
            this.gv_Groups.DataBind();
        }
    报错 无法找到表0 是什么原因?
      

  2.   

    DataSet ds1 = mac.GetOrderComNameList(comname, begin, end);看看这个方法调用成功没,如果没有ds1中为空,所以找不到datable[0]
      

  3.   

    comname, begin, end 这3个都有数据的
      

  4.   

    this.gv_Groups.DataSource = ds1.Tables[0];
      this.gv_Groups.DataBind();直接这样,为什么要放到ds中,再绑定,搞不懂?
      

  5.   

      DataSet ds1 = mac.GetOrderComNameList(comname, begin, end);
    这里可呢没有得到值 确定一下 GetOrderComNameList是否返回了一个DataSet 
      

  6.   

    ds.Tables[0]????从哪来的表呀。
    如楼上直接绑定,真的是多此一举。
      

  7.   

    DataSet ds1 = mac.GetOrderComNameList(comname, begin, end);在数据库中估计没取到数据
    看一下SQL
      

  8.   

     DataSet ds1 = mac.GetOrderComNameList(comname, begin, end);
     this.gv_Groups.DataSource = ds1;
     this.gv_Groups.DataBind();
      

  9.   

     DataSet ds = new DataSet();
    这个ds 没有new 一个 DataTable
    不只这个, DataTable还需要创建和ds1相同的DataColumn
    还没完,添加行的时候用DataRow dr = ds.NewRow();
    再给dr的列赋值:dr[0] = ...........哥们儿,别急慢慢写,就是这么复杂
      

  10.   

    你是错的。
    不需要那么麻烦。
    DataTable dt = mac.GetOrderComNameList(comname, begin, end);
    dt.fill(ds1);