473,770 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bound Combo Box, Lookup Table?

I am used to VB6 but need to develop something in .Net.

I need to create several bound combo-boxes which will use lookup tables to
get their values.

I created a form using the dataform wizard. As part of the setup, I
specified a new dataset, which included the data & lookup tables. I also
specified the relationships when required.

I then added a combo box control to my form, following the instructions from
dynamic help:

I set the datasource for the control to the lookup table.
I set the DisplayMember to the required text column from my lookup table.
I set the ValueMember to the required ID column from my lookup table.

Under DataBindings.Se lectedValue I specified my base table, & relevant
column.
This all appears to work, however the problem appears to arise with null
values.

When the form is loaded & the data is fetched, if the source column for the
lookup is null, the combo displays the first entry in the list of the combo
control.
If I select a value, & select the update button (the form was created with
teh standard settings in the wizard), the correct value is inserted into the
underlying table. However, when I navigate to the next record, if it is
null, again the first value in the list is displayed.
Finally, if I attempt to remove a value from the form (i.e. make it null) &
then update, the update will succeed. However the combo will then update &
show the first entry in the list.

I had a look at the code executing with a watch placed on the SelectedValue
property of the combo. It is always correct until, as part of the
UpdateDataSet sub, the DataSet.Merge method is called. At this point the
first value is displayed in the combo.

Any suggestions for a solution?
Cheers,
James
Nov 20 '05 #1
1 3367
I have now replicated this with from the Combo box demonstration on msdn
(http://msdn.microsoft.com/library/en...lkcreatinglook
uptableondata-boundwindowsfor m.asp?frame=tru e&_r=1)
The file can be found here:
http://www.j.goodman.dsl.pipex.com/f...bleExample.zip

This example also requires the Northwind sample db. If you set the value of
CustomerID to Null for a record, & then load the form it demonstrates this
phenomenon. If the modified record is loaded first, the combo will be blank.
However, if the user navigates to the next (or previous) record, & then back
to the record, the combo will show the first entry in the list.

"James" <j_*********@ya hoo.co.uk> wrote in message
news:82******** *************** *@posting.googl e.com...
I am used to VB6 but need to develop something in .Net.

I need to create several bound combo-boxes which will use lookup tables to
get their values.

I created a form using the dataform wizard. As part of the setup, I
specified a new dataset, which included the data & lookup tables. I also
specified the relationships when required.

I then added a combo box control to my form, following the instructions from dynamic help:

I set the datasource for the control to the lookup table.
I set the DisplayMember to the required text column from my lookup table.
I set the ValueMember to the required ID column from my lookup table.

Under DataBindings.Se lectedValue I specified my base table, & relevant
column.
This all appears to work, however the problem appears to arise with null
values.

When the form is loaded & the data is fetched, if the source column for the lookup is null, the combo displays the first entry in the list of the combo control.
If I select a value, & select the update button (the form was created with
teh standard settings in the wizard), the correct value is inserted into the underlying table. However, when I navigate to the next record, if it is
null, again the first value in the list is displayed.
Finally, if I attempt to remove a value from the form (i.e. make it null) & then update, the update will succeed. However the combo will then update &
show the first entry in the list.

I had a look at the code executing with a watch placed on the SelectedValue property of the combo. It is always correct until, as part of the
UpdateDataSet sub, the DataSet.Merge method is called. At this point the
first value is displayed in the combo.

Any suggestions for a solution?
Cheers,
James

Nov 20 '05 #2

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

Similar topics

2
3453
by: Phil | last post by:
My form uses a dataset containing two tables, a base table (Contact) and a lookup table (Insurer). My combobox is bound as follows: DataSource = datasetContact DisplayMember = Insurer.InsurerName ValueMember = Insurer.InsurerId DataBindings.SelectedValue = Contact.InsurerId It generally works fine. I am able to navigate records and
5
4664
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound combo by allowing the user to dynamically type in the new value directly in the combo box whcih in turn updates the lookup table and then when they have finished leaves that particular cell on the grid with the correct value. Seems...
0
921
by: James | last post by:
I have a bound combo using a lookup table which is behaving as expected with the exception of the first record. In the list of rows for my combo, the first is '.'. This is because of another issue I had with a bound combo box, whereby nulls were populated with values (A known bug with MS). If my first record has a value other than period, when the user first loads the form it is displayed as a period, & subsequently my dataset is...
4
4620
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
1
4865
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1 to limit what is displayed in bound combo box C2. When I display Tbl-A records on a continuous form, and navigate away from record 1 to record 2, the previously entered data displayed in C2 for record 1 disappears from
9
32626
by: Vmusic | last post by:
Hi, I'm using MS Access 2002. I have a form with a combo box built from a query that returns one column, and that one column is the bound column. How do you use VBA to programmatically change which row in the combo box is selected?? I looked at the forum and the answers aren't very clear. Of course the MS Access help file is worthless.
0
1996
by: northshore | last post by:
Hello, I am creating a windows application database. I have a primary table 'Individuals' and a lookup table 'Prefixes.' In the Individuals table, I have a column 'PrefixID' that references values of prefixes from the Prefix table based on the PrefixID in the Prefix table. When I load a windows application form, I can display and update data from the primary table. This includes the prefixID value. If I display a combo box with...
3
3551
by: Jimmy | last post by:
I'm not sure the subject line is a very clear description of my problem so... I have two relevant tables for this issue... the lookup table tblLookupItems with three fields . The control source for my form tblExpenses. In this table there are three relevant fields . On the form the field is set up as a combobox to get
3
2391
by: Jay Ruyle | last post by:
I'm trying to figure out a way to list several items in a listbox and let the user select any number of items in the listbox. I have tried to code in the items as bitwise items but all it stores in the database is the top item in the listbox. How can I get the listbox to add all the bit values to be stored and also come out properly when viewed later? Example:
0
9617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10254
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10036
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8929
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.