| | |
Combo box and C#
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
Hi Guys
I want to change the values in first combo box1 according to values in combo box2.I wore followign coding but it did nt work.I wrote in under SelectedIndexChanged in combo box
Pls give me idea how to slove this problem
Thanks
I want to change the values in first combo box1 according to values in combo box2.I wore followign coding but it did nt work.I wrote in under SelectedIndexChanged in combo box
Pls give me idea how to slove this problem
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=IT-TEMP;Initial Catalog=Test;Integrated Security=True");
string str3 = "Select ExecutiveCode from dbo.Executive where TerritoryCode='"+ this.comboBox2.Text +"'";
con.Open();
SqlCommand command3 = new SqlCommand(str3, con);
SqlDataReader reader = command3.ExecuteReader();
comboBox1.Refresh();
while (reader.Read())
{
this.comboBox1.Items.Add(reader[0].ToString());
}Thanks
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 137
also before adding the items, make sure you call
C# Syntax (Toggle Plain Text)
this.comboBox1.Items.Clear();
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Dec 2006
Posts: 49
Reputation:
Solved Threads: 0
Are you sure 'this.comboBox2.Text ' returns the selected index, (and do you need value or text)?
And make sure that reader[0].ToString() returns the intended value? You may print or debug..
Also, as dickersonka said, clear the combobox not refresh.
And make sure that reader[0].ToString() returns the intended value? You may print or debug..
Also, as dickersonka said, clear the combobox not refresh.
Last edited by sivaslieko++; Sep 11th, 2008 at 2:30 am.
You see things; and you say 'Why?' But I dream things that never were; and I say 'Why not'
![]() |
Similar Threads
- combo box (PHP)
- Want to use radio button or menu bar instead of combo box (Java)
- combo box (ASP)
- How do I limit text char in Combo box? (VB.NET)
- combo box help (VB.NET)
Other Threads in the C# Forum
- Previous Thread: How To Send Data From Client To Server via Server Side (using C# TCP Socket) ?
- Next Thread: how and where to download
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming properties radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tables tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






