473,394 Members | 2,020 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,394 software developers and data experts.

Data Table and Combo Box

Hi,

I have a data table that I created as below.

I am selected using a sql statement to get 1 field to appear in combo box. What I would like to do then is to get the selected items from the underlying data table that match to the item in the combo box.

So if I selected Name A out of the Combo Box I would like to be able to store all of the rest of the contents of the fields that a relevant to Name A either to an array or to Constants as they will not be changing.

Is this possible ? if so how ....

Here is a snippet of my sample code I am using.


Expand|Select|Wrap|Line Numbers
  1.  // Create the data apadter
  2. SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Names ORDER by Name", cs);
  3.  
  4. // Create the Data Table
  5. DataTable dt = new DataTable();
  6.  
  7. // Fill Data Table with Records
  8. da.Fill(dt);
  9.  
  10. // Loop around the table and populate the combo box with records....
  11.  
  12. for (int i = 0; i < dt.Rows.Count; i++)
  13.     {
  14.      cboCouncils.Items.Add(dt.Rows[i]["Name"]);
  15.      }
  16.  
  17.  
Thanks in advance

rdrunner
May 5 '12 #1
1 2022
Hi Again

The above is in c#

rdrunner
May 5 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Brian Mitchell | last post by:
Ok, I know this is an elementary question but I have a data grid that is bound to a data table and I can't seem to find a way to match the selected row in the grid with it's respective row in the...
11
by: Ron L | last post by:
I have a data table that lists a series of items in my database. In my user form, I want the user to be able to filter by a number of criteria (e.g. location, contract, date modified, etc). Other...
1
by: John | last post by:
Hi When using Table Adapter Configuration Wizard if 'Use SQL Statements' is selected as Command Type, the data table's name in dataset is retained and only its data adapter's select statements...
9
by: Kay | last post by:
Hi all, Could you tell me the best way to add a blank item(as first item) in a data binded combo box? Because I think I didn't do it right and it generate an error if the second item(after the...
4
by: Evan | last post by:
I have a data bound combo box. The combo box displays several items (status code descriptions). After the combo box is bound, I want to set the combo box so that the "Draft" status is displayed by...
3
by: anirban | last post by:
I am a novice of VB I want to fetch data from combo box or list which is selected give me a easy way to select the data of combo box or list box I can show data in combo box or list box
3
by: kbannon | last post by:
I have come across a problem whereby occasionally a problem occurs with a data bound combo. The combo has an event which when changed causes a second combo to populate (its also data bound)....
1
by: pavanip | last post by:
Hi, I have a data grid control and I placed one combo box in that data grid and I am binding data to data grid combo box.When i run the application by default the combo box is not showing anything...
3
by: kumardharanik | last post by:
Pls could anyone help me how to get data from combo box with my following code i used txt_app_code for combo box name. using System; using System.Collections.Generic; using...
1
by: BaseballGraphs | last post by:
Hello, I am trying to divide one value from my data table with an associated ID by another value from my data table with a different ID for the same day that the value was added to the data table....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.