473,395 Members | 1,869 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,395 software developers and data experts.

Displaying Data in Comboboxes (C#)

1
Hi,

I'd like to be able to populate data into a textbox by choosing an item in a combobox using C#. I've managed to do this to an extent - the from the database appear in the combobox but I cannot get the textbox to populate. Basically, when you select the CompanyName from the combobox the CompanyID should be shown in the textbox. Below is the code I have and the error I'm getting:

Expand|Select|Wrap|Line Numbers
  1.  
  2. namespace STLSystem
  3. {
  4.     public partial class Client : Form
  5.     {
  6.         private DataSet myDataSet;
  7.         private string connectionString;
  8.  
  9.         public Client(DataSet myDataSet, string connectionString)
  10.         {
  11.             InitializeComponent();
  12.             this.myDataSet = myDataSet;
  13.             this.connectionString = connectionString;
  14.             myDataSet = new DataSet();
  15.             this.BindComboBox(myDataSet, connectionString);
  16.  
  17.         }
  18.  
  19.         private void BindComboBox(DataSet myDataSet, string connectionString)
  20.         {
  21.             OleDbConnection myConnection = new OleDbConnection(connectionString);
  22.             OleDbDataAdapter myDataAdapter = new OleDbDataAdapter("SELECT * FROM Company", myConnection);
  23.             myDataAdapter.TableMappings.Add("Table", "Company");
  24.             myDataAdapter.Fill(myDataSet);
  25.  
  26.             this.dviewmanager = myDataSet.DefaultViewManager;
  27.             DataTable myDataTable = myDataSet.Tables[0];
  28.             //bind it with comboBox1
  29.             comboBox1.DataSource = myDataTable;
  30.  
  31.             comboBox1.DisplayMember = "CompanyName";
  32.             this.textBox5.DataBindings.Add("Text", this.dviewmanager, "Company.CompanyID");
  33.             //set the display index for first item to be displayed
  34.             comboBox1.SelectedIndex = 0;
  35.         }
  36.  
  37.  
Error 1 'STLSystem.Client' does not contain a definition for 'dviewmanager' and no extension method 'dviewmanager' accepting a first argument of type 'STLSystem.Client' could be found (are you missing a using directive or an assembly reference?)

Any help would be greatly appreciated.

Thanks
Jan 21 '08 #1
0 1235

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

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...
2
by: edworboys | last post by:
I have designed a data entry form with a number of fields and a sub form. The first field (Country) is a combo box and the user selects a country. This, in turn reduces the number of options in the...
9
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There...
1
by: Nikhil Patel | last post by:
Hi All, I am using a dll function that returns a two diamensional array containing BankNames and RoutingIds. I need to display BankNames and RoutingIds in two different comboboxes. When user...
4
by: David Meier | last post by:
How can data be stored in comboboxes similar to html pulldowns? I know I can access the data of the combobox either by the items text or by its index. However, I would like to have a pulldown...
15
by: Bo Diddly | last post by:
Hi everyone, I am relatively new to VB.Net, and database programming. I have a database with four tables, set up as follows: tblBook BookID... key Book... All the book titles of the Bible...
4
by: Vish | last post by:
Hi, I am having a problem with my form being too slow to load up. I have a 4-5 of comboboxes on the form that load a lot (~30,000 records) into them. So this is causing a lot delay (5-6 seconds)...
0
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue...
1
by: tizmagik | last post by:
I have a combobox on a continuous form that has a recordsource that is set upon Form_Load event via VBA (based on initial form data and external form data entered). For data entry purposes the...
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: ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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
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.