根据所选内容过滤我的gridView [英] Filterering my gridView acording to the selected

查看:78
本文介绍了根据所选内容过滤我的gridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们

在下面,我想过滤我的gridView并根据选定的选项对其进行更新...现在,它仅对datagrid进行伪造,但是当我尝试对选定的内容进行过滤时,它却无能为力...请帮助

Hi Guys

Below I want to filter my gridView and update it acording to the selected option...now the It only pupulates the datagrid but when i try to filter acording to the selected its not doing nothing...Please help

public void populateGridView()
       {

           studentMarksTableAdapter = new OleDbDataAdapter();
           studentsDataSet = new DataSet();
           studentMarksTableAdapter.SelectCommand = dbCmd;
           studentMarksTableAdapter.Fill(studentsDataSet, "StudentMarks");
           gridViewAll.DataSource = studentsDataSet.Tables[0];
       }
       private void Form1_Load(object sender, EventArgs e)
       {

           // Connect to Database:
           string sConnection = "Provider = Microsoft.Ace.OLEDB.12.0;Data Source=Students.accdb";
           dbConn = new OleDbConnection(sConnection);
           dbConn.Open();

           //  Connect the Command to the Connection:
           sql = "SELECT  * FROM StudentMarks ";

           dbCmd = new OleDbCommand();
           dbCmd.CommandText = sql;
           dbCmd.Connection = dbConn;


           populateGridView();



           dbConn.Close();
       }

       private void cboFilter_SelectedIndexChanged(object sender, EventArgs e)
       {
           if (cboFilter.Text == "Student Number")
           {
               sql += "Order By StudentNumber ASC";
               populateGridView();
           }
       }

推荐答案

您是否调用了诸如databind之类的东西来刷新gridview?
我熟悉结合MySQL数据库处理数据库系统的gridview,但不熟悉您使用的数据集.通常,您需要先刷新数据源,然后再刷新gridview,例如调用gridview1.DataBind();
Did you call something like databind to refresh the gridview?
I am familiar with gridview combining MySQL database to handle the database system, but not familiar with the dataset you use. Typically you need to refresh the datasource first then refresh the gridview, like calling gridview1.DataBind();


这篇关于根据所选内容过滤我的gridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆