473,408 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Deaking with ComboBoxes and databases

Hi,
I have a couple of combo boxes and the data inthe combo boxes is
from the SQL database. I have created datasets to reflect that data in
one of the combo box.
But, what I want is that, when I select certain data from one combo
box, the data in other comboBox should automatically reflect the
related data from the first combo box.
For example, If I select a state IL from comboBox1 (from dataset from
sql database "state" column), then the values in comboBox2 should
automatically reflect only cities from IL (from the sql database table
"city" column).

Can anyone assist?? I would appreciate if anyone can even give me
references for related examples.
Thanks,

Mar 16 '06 #1
3 1057
vj
First combo box

lstSelectItem.DataSource = null;
lstSelectItem.DataSource = dtSelect;
lstSelectItem.DisplayMember = "Name";
lstSelectItem.ValueMember = "ID";
In selectedIndexchange of the above.. u could write the below

private void lstSelectItem_SelectedValueChanged(object sender, EventArgs
e)
{
lstLinked.DataSource = null;
DataRowView dtView = ((DataRowView)lstSelectItem.SelectedItem);
int intLocalUnqiueID = int.Parse(dtView["ID"].ToString());
dvLinked.RowFilter = "ID = " + intLocalUnqiueID;
lstLinked.DataSource = dvLinkedRows;
lstLinked.DisplayMember = "Name";
lstLinked.ValueMember = "ID";
}

HTH
VJ
"juventusaurabh" <sa************@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Hi,
I have a couple of combo boxes and the data inthe combo boxes is
from the SQL database. I have created datasets to reflect that data in
one of the combo box.
But, what I want is that, when I select certain data from one combo
box, the data in other comboBox should automatically reflect the
related data from the first combo box.
For example, If I select a state IL from comboBox1 (from dataset from
sql database "state" column), then the values in comboBox2 should
automatically reflect only cities from IL (from the sql database table
"city" column).

Can anyone assist?? I would appreciate if anyone can even give me
references for related examples.
Thanks,

Mar 16 '06 #2
Hi VJ,
Thanks, But Iam not able to figure what is dvLinked.RowFilter
in ur snippet. Can you please explain what is dvLinked?

Mar 16 '06 #3
vj
Sorry my bad.. it has to be dvLinkedRows. essentially u filter dvLinkedRows
and then set the filtered thing to the source.

VJ

"vj" <vi********@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
First combo box

lstSelectItem.DataSource = null;
lstSelectItem.DataSource = dtSelect;
lstSelectItem.DisplayMember = "Name";
lstSelectItem.ValueMember = "ID";
In selectedIndexchange of the above.. u could write the below

private void lstSelectItem_SelectedValueChanged(object sender, EventArgs
e)
{
lstLinked.DataSource = null;
DataRowView dtView = ((DataRowView)lstSelectItem.SelectedItem);
int intLocalUnqiueID = int.Parse(dtView["ID"].ToString());
dvLinked.RowFilter = "ID = " + intLocalUnqiueID;
lstLinked.DataSource = dvLinkedRows;
lstLinked.DisplayMember = "Name";
lstLinked.ValueMember = "ID";
}

HTH
VJ
"juventusaurabh" <sa************@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Hi,
I have a couple of combo boxes and the data inthe combo boxes is
from the SQL database. I have created datasets to reflect that data in
one of the combo box.
But, what I want is that, when I select certain data from one combo
box, the data in other comboBox should automatically reflect the
related data from the first combo box.
For example, If I select a state IL from comboBox1 (from dataset from
sql database "state" column), then the values in comboBox2 should
automatically reflect only cities from IL (from the sql database table
"city" column).

Can anyone assist?? I would appreciate if anyone can even give me
references for related examples.
Thanks,


Mar 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kathy | last post by:
In my custom menu one menu item opens a form to add new Makes to TblMakes and another menu item opens a form to add new Models to TblModels. I have a form that has a combobox for Makes and a...
0
by: johnson_cy | last post by:
I am using Access 2000. My main form has a record source of a table (employeeTbl with key of . It is filtering the record results. My subform and mainform have the link child/link master set...
1
by: Craig G | last post by:
for months we have been dabling round looking at various 3rd party comboboxes that allow the user to type text into the combobox as a search mechanism what we've found is that the likes of...
1
by: Marcin Podle¶ny | last post by:
Hi, I've a form with three comboboxes. Each of them contains the same data - all cities in my country. As you see it's a lot of data so it takes a lot of memory. I'd like to use the same...
6
by: Sam | last post by:
Hi, I have a datagrid which has (amongst other stuff) 2 comboboxes columns. So far so good. The trick is that when I select a value in my first column, it must updates the items of the combobox in...
2
by: ashishtarlekar | last post by:
Hi all, I have to add comboboxes in the first row of datagridview for mapping the database fields. For e.g. I have to show Id, FirstName, LastName in each comboboxes in the first row. if i select...
2
by: Matt | last post by:
Hi all, me again! :) I've now got an issue with combo boxes. Basically, I have a number of items that I want a user to pick from a single list. It's basically along the lines of: Fruit 1: ...
3
by: Randy | last post by:
I have a routine that creates a series of comboboxes, each of which is bound to a common dataview. Everything used to work fine, but now, when I change the value of any of the comboboxes, the...
5
by: Anthony Bollinger | last post by:
I have two tables in a master-detail relationship. When I make a selection in one combobox, how do I have it display the values from a second combobox? Each table has a key and a text value for...
2
by: Wingot | last post by:
Hey, I have a view to a database that I have created for Client Maintenance. It has a number of fields, but the important ones are Medical Condition, Bill To, and Country. I have a couple of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.