0
私はタブコントロールを持っています。それは9個のタブページコレクションを持っています。各タブページには、データグリッドビューと検索ボックスがあります。データグリッドビューのデータをクリアする
private void txtsrchesd_TextChanged(object sender, EventArgs e)
{
if (txtsrchesd.Text == "")
{
}
else
{
string constring = @"Data Source=JAY\J_SQLSERVER;Initial Catalog=FillingDatabase;User ID=jay;Password=pass1234";
string query = " SELECT * FROM esd_view where department like '" + txtsrchesd.Text + "%' order by department ";
SqlConnection scon = new SqlConnection(constring);
SqlCommand cmd = new SqlCommand(query, scon);
SqlDataReader dr;
DataTable dt = new DataTable();
SqlDataAdapter sql = new SqlDataAdapter(query, scon);
sql.Fill(dt);
sql.Dispose();
dgesd.DataSource = dt;
memoDatabaseDataSetBindingSource.DataSource = dt.DefaultView;
}
}
private void txtsrchope_TextChanged(object sender, EventArgs e)
{
if (txtsrchope.Text == "")
{
}
else
{
string constring = @"Data Source=JAY\J_SQLSERVER;Initial Catalog=FillingDatabase;User ID=jay;Password=pass1234";
string query = " SELECT * FROM operations_view where department like '" + txtsrchope.Text + "%' order by department ";
SqlConnection scon = new SqlConnection(constring);
SqlCommand cmd = new SqlCommand(query, scon);
SqlDataReader dr;
DataTable dt = new DataTable();
SqlDataAdapter sql = new SqlDataAdapter(query, scon);
sql.Fill(dt);
sql.Dispose();
dgoper.DataSource = dt;
memoDatabaseDataSetBindingSource.DataSource = dt.DefaultView;
}
}
私は
はあなたが理解してほしい私の検索ボックスに入力する内容クリアするように、他のDataGridViewの出力が他のDataGridViewに表示され、どのように私は助けてくれてありがとう、DataGridViewのの出力をクリアすることができます
をあなたの質問は何ですか? –
@ S.Akbari、どのように私は私の検索ボックスに何を入力するのをクリアすると、DataGridViewの出力をクリアすることができますか? – mhitzsuiko
テキストボックスのいずれかに値がない場合、データグリッドビューにデータがないようにしたいですか?この回答をご覧ください: http://stackoverflow.com/questions/13137591/how-to-clear-a-data-grid-view – Draken