datagridview查询解决方案

前提:datagridview已绑定

  1.         private void toolStripButton1_Click(object sender, EventArgs e)
  2.         {
  3.            
  4.             DataView dv = vIEW_Student_DataSet.Tables[0].DefaultView;
  5.             string stud = toolStripTextBox_Stud.Text;
  6.             if (stud.Length != 0)
  7.             {
  8.                 dv.RowFilter = "StudID = '" + stud + "'";    //筛选条件为StudID列
  9.                 dataGridView_Select.DataSource = dv;        //将筛选后的表绑定给datagridview
  10.             }
  11.             else
  12.                 this.vIEW_StudentTableAdapter.Fill(this.vIEW_Student_DataSet.VIEW_Student);    //重新填充datagridview
  13.          }

说明: dataGridView_Select为定义的datagridview的实例名

            vIEW_Student_DataSet为定义的dataset的实例名

            VIEW_Student为绑定的视图的名称

你可能感兴趣的:(dataset)