C#
I have some combo boxes, full of lookup descriptions. When I retrieve a
dataset for my record, the values that need binding to the combos are the
actual record IDs that relate to these lookup descriptions. How do I bind
them up in this case?
Thanks
Steve 4 2489
Hi Steve,
I'm not exactly sure of what you are asking for, but I suspect you may be looking for the ValueMember/DisplayMember properties of the ComboBox. Typically the DisplayMember is the column the describes the entry and ValueMember the column that contains the id.
On Mon, 19 Sep 2005 14:39:26 +0200, Steve <St***@discussi ons.microsoft.c om> wrote: C#
I have some combo boxes, full of lookup descriptions. When I retrieve a dataset for my record, the values that need binding to the combos are the actual record IDs that relate to these lookup descriptions. How do I bind them up in this case?
Thanks
Steve
--
Happy coding!
Morten Wennevik [C# MVP]
When the user enters the screen to modify a record, I populate a dataset row
with all the values from the DB, then I am trying to bind that set into the
screen, so I can capture all the changes, then return the dataset to the
server to commit the changes. With text fields I can bind them no problems,
and the value is displayed nice and easy. But with the combos, the value
stored is the ID field of the combo box. How do I tie these together so the
combo is changed to show the correct descriptor and how do I then get the
combo change to change the value in the dataset?
Thanks
Steve
"Morten Wennevik" wrote: Hi Steve,
I'm not exactly sure of what you are asking for, but I suspect you may be looking for the ValueMember/DisplayMember properties of the ComboBox. Typically the DisplayMember is the column the describes the entry and ValueMember the column that contains the id.
On Mon, 19 Sep 2005 14:39:26 +0200, Steve <St***@discussi ons.microsoft.c om> wrote:
C#
I have some combo boxes, full of lookup descriptions. When I retrieve a dataset for my record, the values that need binding to the combos are the actual record IDs that relate to these lookup descriptions. How do I bind them up in this case?
Thanks
Steve
-- Happy coding! Morten Wennevik [C# MVP]
Your scenario is still not entirely clear to me, but that may be my fault :)
Correct me if I'm wrong, but I'm guessing you have an ID field in your row representing data from another table and want the id number translated to this data, with the ComboBox selection tied to that table (Lookup Table).
Maybe this page can be of some use (beware of line breaks): http://msdn.microsoft.com/library/de...boxcontrol.asp
On Mon, 19 Sep 2005 15:51:00 +0200, Steve <St***@discussi ons.microsoft.c om> wrote: When the user enters the screen to modify a record, I populate a dataset row with all the values from the DB, then I am trying to bind that set into the screen, so I can capture all the changes, then return the dataset to the server to commit the changes. With text fields I can bind them no problems, and the value is displayed nice and easy. But with the combos, the value stored is the ID field of the combo box. How do I tie these together so the combo is changed to show the correct descriptor and how do I then get the combo change to change the value in the dataset?
Thanks
Steve
"Morten Wennevik" wrote:
Hi Steve,
I'm not exactly sure of what you are asking for, but I suspect you may be looking for the ValueMember/DisplayMember properties of the ComboBox. Typically the DisplayMember is the column the describes the entry and ValueMember the column that contains the id.
On Mon, 19 Sep 2005 14:39:26 +0200, Steve <St***@discussi ons.microsoft.c om> wrote:
> > C# > > I have some combo boxes, full of lookup descriptions. When I retrieve a > dataset for my record, the values that need binding to the combos are the > actual record IDs that relate to these lookup descriptions. How do I bind > them up in this case? > > Thanks > > Steve > -- Happy coding! Morten Wennevik [C# MVP]
--
Happy coding!
Morten Wennevik [C# MVP]
Hello Steve,
I had the same issue a few days ago. It took me awhile to realize that I was
grabbing the combo box index, not record Id!!!
Anyways, my combo boxes are used in a User Control so you will need to do
something slightly different for a generic combo box.
Basically, I access the underlying List that contains the record information
from the DataSource.
I did this to capture the Record_Id from the Selected List Item:
return
(int)(((System. Data.DataRowVie w(cmboxPersonne lType.SelectedI tem)).Row.ItemA rray[0]);
1) ComboBox.Select edItem = Returns an object (Data row with your data)
2) Take the object from ComboBox.Select edItem -Or- ComboBox.Item (?) and
cast it to a DataRowView. DataRow should work too.
3) Use the ItemArray property to find the field that you need. The Record_Id
should be an integer.
And that's how you can get your record id without doing too much work. I use
a property to retrieve it.
public int PersonnelTypeRe cordID
{
get
{
return
(int)(((System. Data.DataRowVie w)(cmboxPersonn elType.Selected Item)).Row.Item Array[0]);
}
}
"Steve" wrote:
>
When the user enters the screen to modify a record, I populate a dataset row
with all the values from the DB, then I am trying to bind that set into the
screen, so I can capture all the changes, then return the dataset to the
server to commit the changes. With text fields I can bind them no problems,
and the value is displayed nice and easy. But with the combos, the value
stored is the ID field of the combo box. How do I tie these together so the
combo is changed to show the correct descriptor and how do I then get the
combo change to change the value in the dataset?
Thanks
Steve
"Morten Wennevik" wrote:
Hi Steve,
I'm not exactly sure of what you are asking for, but I suspect you may be looking for the ValueMember/DisplayMember properties of the ComboBox. Typically the DisplayMember is the column the describes the entry and ValueMember the column that contains the id.
On Mon, 19 Sep 2005 14:39:26 +0200, Steve <St***@discussi ons.microsoft.c omwrote:
>
C#
>
I have some combo boxes, full of lookup descriptions. When I retrieve a
dataset for my record, the values that need binding to the combos are the
actual record IDs that relate to these lookup descriptions. How do I bind
them up in this case?
>
Thanks
>
Steve
>
--
Happy coding!
Morten Wennevik [C# MVP]
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: kakss |
last post by:
Hi
I have a Winforms Datagrid and created myDataView and bind to datagrid.
It works great.
DataGrid1.SetDataBinding(myDataView, "")
Above code line shows me below data in datagrid.
CustomerID CustomerName City
|
by: Steve |
last post by:
C#
I have some combo boxes, full of lookup descriptions. When I retrieve a
dataset for my record, the values that need binding to the combos are the
actual record IDs that relate to these lookup descriptions. How do I bind
them up in this case?
Thanks
Steve
|
by: Don Sealer |
last post by:
I have a form that is based on a table called CVA Defects Table. Three
of the fields in the table and form are Oil line defects, Gas line
defects, and Sub assembly defects. These fields use lookups into
another table called "defects table". If I input from the CVA Defects
Table everything works fine all the time. However when I input data
from the form I have problems.
The Oil & Gas line lookups work very well all the time in the form....
|
by: Ken Powers |
last post by:
Hello everyone,
I'm getting a strange error when I try to bind a combo box to a Dataset.
Here's my code!
Private Sub Get_Data()
Try
Dim sqlcmd = New SqlCommand("Select * from Utility order by
Utility", sqlConn)
|
by: Ken Powers |
last post by:
Hello everyone,
Sorry about the repost, my second VB.NET App is done with the exception of
this error.
I'm getting a strange error when I try to bind a combo box to a Dataset.
Here's my code!
Private Sub Get_Data()
Try
Dim sqlcmd = New SqlCommand("Select * from Utility order by
| |
by: Travis |
last post by:
I am new to VB.NET and I am trying to use a complex bind for a combo
box. I have successfully created a data set, I have set my DataSource
value to the dataset and the DisplayMember value to the field in the
dataset I wish to utilize. When I run the form the combo box has no
information. What am I doing wrong?
Thanks!!
Travis
|
by: A_PK |
last post by:
I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only allow user to filter the first time,
when they tried the second time, the speficied cast error message will
prompt one....
I create a mydataset1 first, and the mydataset1 data source was getting from
DataGrid.DataSource.
|
by: tlyczko |
last post by:
I read about limiting combo boxes' list data, for example, limiting the
list of values in the second combo based on values in the first combo,
and I found the Dev Ashish site link.
I have two combos based on lookups of very small tables, Audit
Descriptions and Programs.
Combo 1: Audit Descriptions has Comprehensive, Fire Safety, Medical,
MSC, Snapshot.
Combo 2: Programs has A, B, C, D, E, F, G, H (for example).
|
by: Guy007 |
last post by:
I have a dataset with one table, which has a column "Description" in it. the dataset is populated with data.
i want to bind the dataset to the combo. i'm doing it as follows:
cb.DataSource=myDataSet.Tables;
cb.DisplayMember = "Description";
cb.ValueMember = "Description";
Problem is my Combobox remains with 0 items instead of the 80 rows in the datasource!!!
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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...
| |