我要实现查找:一个TextBox 一个按钮,一个GridView,我点按钮查找,内容在GridView里面显示出来,怎么做?我想要具体的源代码参考

解决方案 »

  1.   

    按钮事件重新更新GridView源啊
      

  2.   

    按钮事件里 把查询出来的数据集 重新绑定到 gridview
      

  3.   

    数据访问层代码你会写吗?string  sql="select * from table where name="+'"TextBox.Text"';DataSet ds=Fill(sql);
    GridView.DataSource=ds;GridView.DataBind();
    Fill方法是个查询方法   你自己写个就是了
      

  4.   

     string sql = "select * from表明 where  条件 order by DemandNum desc";
           DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.conStr, CommandType.Text, sql, null);
     this.GridView.DataSource = ds .Tables[0];
                this.GridView.DataBind();
      

  5.   

    private void GetData(string selectCommand)
    {
        try
        {
            String connectionString =
                "Integrated Security=SSPI;Persist Security Info=False;" +
                "Initial Catalog=Northwind;Data Source=localhost";
            dataAdapter = new SqlDataAdapter(selectCommand, connectionString);        SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);        DataTable table = new DataTable();
            table.Locale = System.Globalization.CultureInfo.InvariantCulture;
            dataAdapter.Fill(table);
            bindingSource1.DataSource = table;        dataGridView1.AutoResizeColumns( 
                DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
        }
        catch (SqlException)
        {
            MessageBox.Show("To run this example, replace the value of the " +
                "connectionString variable with a connection string that is " +
                "valid for your system.");
        }
    }