查询完成后,DataGridView上显示出了想查询的内容,再进行下一次查询时让DataGridView只显示出这一次新查询出来的结果,这个应该怎样做啊

解决方案 »

  1.   

    DataGridView.DataBind()每次邦定都都要加这个!
      

  2.   

    DataGridView.DataSource = DataTable;
    DataGridView.DataBind();
      

  3.   

    查询一次,绑定一次,如下: //dataGridView 数据源已绑定 this.bindingSource
     protected virtual void SetDataSource(string strSql, string strWhere, string strOrder, bool isFirstLoad)
            {
                if (m_BLLCommon == null) return;            this.dataSet = m_BLLCommon.GetDataSet(strSql, strWhere, strOrder, isFirstLoad);
                this.bindingSource.DataSource = this.dataSet.Tables[0].DefaultView;
                this.bindingSource_PositionChanged(null, null);
            }
      

  4.   

    DataGridView.DataSource重新设置一下就行了。要注意数据源应该使用New新建立一个,否则可能会把上一次的数据合并起来。比如DataSet会自动的合并原来的数据。