Click here to Skip to main content
15,911,762 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends i need one help
i am using one window a application with c#.i have two Comboboxs

Combobox1(CB1) and Comboboxs2(CB2).both are already attached with datafields.be
i want when i select the value one from CB1 and second value CB2 then datagridview1 should be display .
my codes are




C#
try
{


con = new SqlConnection("Data Source=.;Initial Catalog=DSIIDC2;Integrated Security=True");
con.Open();
string str = "select * from addcaasedetails";

SqlDataAdapter da = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow row in ds.Tables[0].Rows)
{
if (ds.Tables[0].Rows[1]["caseno"] == comboBox1.SelectedItem && ds.Tables[0].Rows[1]["caseno"]==comboBox2.SelectedItem)
{
dataGridView1.Visible = true;
}

}

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Posted
Updated 28-May-15 20:40pm
v2
Comments
Richard MacCutchan 29-May-15 3:21am    
Are you sure that you are actually comparing the values of the items in the dataset and comboboxes?
Aditya Chauhan 29-May-15 3:47am    
I think you forgot bind the data set with datagridview

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900