1
Reply

how to display the information in gridview when item selected in combobox?

roy himanshu

roy himanshu

Sep 7 2009 7:20 AM
4.3k

hi,
iam working in windows application in C#.if i select one item in combobox then immediatly that item information is displayed in gridview?how? i tryied but it is not working.my codeing past bellow.
private
void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string s;

s = comboBox1.Text.ToString();
cn =
new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["con"]);
SqlCommand cmd = new SqlCommand("select * from CATABLE001 where column005=(select column001 from CATABLE005 where column002='@COLUMN002')", cn);
da2 =
new SqlDataAdapter();
ds =
new DataSet();
cmd.Connection = cn;
da2.SelectCommand = cmd;
da2.Fill(ds,
"CATABLE001");
dataGridView1.DataSource = ds.Tables[0];
}
plz help me
thanx
himanshu

Answers (1)