DropDown Boxes for data entry of fixed fields | Bytes (2025)

Wingot

Hey,

I have a program I am trying to write using Visual C#, SQL Server
2005/2008, and Visual Studio 2008, and one part of it includes a Schema
called Client. Inside this schema, three tables exist named Country,
MedicalCondition, and Customer.

The Customer table includes various fields, but the important ones for
this problem are MedicalCondition, Country, BillTo, EmergencyContact1
and EmergencyContact2.

What I want to do is have each of these five fields, which are linked
via foreign keys, as selectable dropdown boxes. The Customer entry view
is using Details view, not a DataGrid view, and so I am having
difficulty figuring out how to do this.

As an example, when someone clicks on the dropdown for MedicalCondition,
it should display the MedicalCondition.Name fields as the options. When
they select one, it places the MedicalCondition.MedicalConditionID into
the MedicalCondition field of the Customer database.

Any help greatly appreciated.

Regards,

Wingot

Dec 2 '07 #1

Subscribe Reply

8 DropDown Boxes for data entry of fixed fields | Bytes (1) 2913 DropDown Boxes for data entry of fixed fields | Bytes (2)

Nicholas Paldino [.NET/C# MVP]

Wingot,

First, you need to make sure that you have the data loaded for those
tables. Once you have that, you can set the dropdowns to use those for the
list through the DataSource/DataMember properties.

You would also bind the value to the field that contains the id.

The glue that wraps this all up is the DisplayMember and ValueMember
properties on the dropdown. You would set the DisplayMember property to the
member you wish to display in the drop down, while the ValueMember would be
set to the member which would provide the value which would be used for the
binding for the value.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Wingot" <wi****@newsgroup.nospamwrote in message
news:0906E608E66E4488BDEA7C9EF569AF8E@PROMETHEUS.. .
Hey,

I have a program I am trying to write using Visual C#, SQL Server 2005/2008,
and Visual Studio 2008, and one part of it includes a Schema called Client.
Inside this schema, three tables exist named Country, MedicalCondition, and
Customer.

The Customer table includes various fields, but the important ones for this
problem are MedicalCondition, Country, BillTo, EmergencyContact1 and
EmergencyContact2.

What I want to do is have each of these five fields, which are linked via
foreign keys, as selectable dropdown boxes. The Customer entry view is using
Details view, not a DataGrid view, and so I am having difficulty figuring
out how to do this.

As an example, when someone clicks on the dropdown for MedicalCondition, it
should display the MedicalCondition.Name fields as the options. When they
select one, it places the MedicalCondition.MedicalConditionID into the
MedicalCondition field of the Customer database.

Any help greatly appreciated.

Regards,
Wingot

Dec 2 '07 #2

Steven Cheng[MSFT]

Hi Wingot,

From your description, my understanding is that you want to build a data
page for data inserting and for the record to inserting, it may contain
several fields and these fields need to be selected via some
dropdownlists(these lists will display human readable name and actually
send the underlying ID into database), correct?

As for such case, I think you can use the following approach:

** you can use multiple datasource controls and each one bind to a certain
list(each datasource use a query to selected the list of a certain field)

**Your DetailsView may connect to database through another datasource and
the query for this datasource will return the underlying ID for those
fields. thus, you just bind those ID value to the SelectedValue of those
DropDownlists

How do you think? If there is anything unclear, please feel free to post
here.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

=

--------------------

>From: "Wingot" <wi****@newsgroup.nospam>
Subject: DropDown Boxes for data entry of fixed fields
Date: Sun, 2 Dec 2007 15:44:43 +0900

Hey,

I have a program I am trying to write using Visual C#, SQL Server
2005/2008, and Visual Studio 2008, and one part of it includes a Schema
called Client. Inside this schema, three tables exist named Country,
MedicalCondition, and Customer.

The Customer table includes various fields, but the important ones for
this problem are MedicalCondition, Country, BillTo, EmergencyContact1
and EmergencyContact2.

What I want to do is have each of these five fields, which are linked
via foreign keys, as selectable dropdown boxes. The Customer entry view
is using Details view, not a DataGrid view, and so I am having
difficulty figuring out how to do this.

As an example, when someone clicks on the dropdown for MedicalCondition,
it should display the MedicalCondition.Name fields as the options. When
they select one, it places the MedicalCondition.MedicalConditionID into
the MedicalCondition field of the Customer database.

Any help greatly appreciated.

Regards,

Wingot

Dec 3 '07 #3

Wingot

Hi Steven,

AS for creating multiple datasources, I had attempted to do this, and
despite the fact that in Preview Data it worked, I couldn't get it to
display anything in the dropdown boxes (or Combobox controls to be
technical) once I had associated the data.

I will have another look at it when I get home, and will post an update.

Regards,
Wingot

-----Original Message-----
From: Steven Cheng[MSFT] [mailto:st*****@online.microsoft.com]
Posted At: Monday, 3 December 2007 7:34 PM
Posted To: microsoft.public.dotnet.languages.csharp
Conversation: DropDown Boxes for data entry of fixed fields
Subject: RE: DropDown Boxes for data entry of fixed fields

Hi Wingot,

From your description, my understanding is that you want to build a
data
page for data inserting and for the record to inserting, it may

contain

several fields and these fields need to be selected via some
dropdownlists(these lists will display human readable name and

actually

send the underlying ID into database), correct?

As for such case, I think you can use the following approach:

** you can use multiple datasource controls and each one bind to a
certain
list(each datasource use a query to selected the list of a certain
field)

**Your DetailsView may connect to database through another datasource
and
the query for this datasource will return the underlying ID for those
fields. thus, you just bind those ID value to the SelectedValue of
those
DropDownlists

How do you think? If there is anything unclear, please feel free to
post
here.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.

=

--------------------

From: "Wingot" <wi****@newsgroup.nospam>
Subject: DropDown Boxes for data entry of fixed fields
Date: Sun, 2 Dec 2007 15:44:43 +0900

Hey,

I have a program I am trying to write using Visual C#, SQL Server
2005/2008, and Visual Studio 2008, and one part of it includes a

Schema
called Client. Inside this schema, three tables exist named Country,
MedicalCondition, and Customer.

The Customer table includes various fields, but the important ones

for

this problem are MedicalCondition, Country, BillTo, EmergencyContact1
and EmergencyContact2.

What I want to do is have each of these five fields, which are linked
via foreign keys, as selectable dropdown boxes. The Customer entry

view
is using Details view, not a DataGrid view, and so I am having
difficulty figuring out how to do this.

As an example, when someone clicks on the dropdown for

MedicalCondition,
it should display the MedicalCondition.Name fields as the options.
When
they select one, it places the MedicalCondition.MedicalConditionID
into
the MedicalCondition field of the Customer database.

Any help greatly appreciated.

Regards,

Wingot

Dec 4 '07 #4

Wingot

Hey Nicholas,

Sorry that I had not responded earlier, have been rather busy the past
two days.

I had done this, and got it to work for a time in the Country field,
using a Combobox. I have subsequently broken it when trying to get
Medical Condition to work, and it now no longer displays anything in
that Combobox, but the fact that I have seen it in action gives me hope.

As a query, there is no reason why this shouldn't work for a recursive
field is there? Specifically, the Customer table refers back to itself
for the Bill To and Emergency Contact #1 and #2 fields.

Regards,
Wingot

-----Original Message-----
From: Nicholas Paldino [.NET/C# MVP]
[mailto:mv*@spam.guard.caspershouse.com]
Posted At: Sunday, 2 December 2007 10:33 PM
Posted To: microsoft.public.dotnet.languages.csharp
Conversation: DropDown Boxes for data entry of fixed fields
Subject: Re: DropDown Boxes for data entry of fixed fields

Wingot,

First, you need to make sure that you have the data loaded for
those
tables. Once you have that, you can set the dropdowns to use those

for

the
list through the DataSource/DataMember properties.

You would also bind the value to the field that contains the id.

The glue that wraps this all up is the DisplayMember and
ValueMember
properties on the dropdown. You would set the DisplayMember property
to the
member you wish to display in the drop down, while the ValueMember
would be
set to the member which would provide the value which would be used

for

the
binding for the value.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Wingot" <wi****@newsgroup.nospamwrote in message
news:0906E608E66E4488BDEA7C9EF569AF8E@PROMETHEUS.. .
Hey,

I have a program I am trying to write using Visual C#, SQL Server
2005/2008,
and Visual Studio 2008, and one part of it includes a Schema called
Client.
Inside this schema, three tables exist named Country,

MedicalCondition,

and
Customer.

The Customer table includes various fields, but the important ones for
this
problem are MedicalCondition, Country, BillTo, EmergencyContact1 and
EmergencyContact2.

What I want to do is have each of these five fields, which are linked
via
foreign keys, as selectable dropdown boxes. The Customer entry view is
using
Details view, not a DataGrid view, and so I am having difficulty
figuring
out how to do this.

As an example, when someone clicks on the dropdown for
MedicalCondition, it
should display the MedicalCondition.Name fields as the options. When
they
select one, it places the MedicalCondition.MedicalConditionID into the
MedicalCondition field of the Customer database.

Any help greatly appreciated.

Regards,
Wingot

Dec 4 '07 #5

Steven Cheng[MSFT]

Hi Wingot,

Thanks for your reply.

For multiple datasource control, if the field list is constant or not
frequently changed, you can apply Cache on each of them so that they will
not impact the page's performance much.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

>From: "Wingot" <wi****@newsgroup.nospam>
References: <0906E608E66E4488BDEA7C9EF569AF8E@PROMETHEUS>

<$b**************@TK2MSFTNGHUB02.phx.gbl>

>In-Reply-To: <$b**************@TK2MSFTNGHUB02.phx.gbl>
Subject: Re: DropDown Boxes for data entry of fixed fields
Date: Tue, 4 Dec 2007 09:03:48 +0900

Hi Steven,

AS for creating multiple datasources, I had attempted to do this, and
despite the fact that in Preview Data it worked, I couldn't get it to
display anything in the dropdown boxes (or Combobox controls to be
technical) once I had associated the data.

I will have another look at it when I get home, and will post an update.

Regards,
Wingot

>>

Dec 4 '07 #6

Wingot

Hey,

I have attempted to add another BindingSource, for Country. The
DataMember is Country, DataSource is wingFlexClientDataSet. This is the
same DataSet that is being used for the customerBindingSource that
works. wingFlexClientDataSet is a DataSet that includes the complete
Client Schema, which includes Customer, Country, and MedicalCondition.

When I then set up a Data Binding for the DataSource
FK_Customer_Country, which has the Customer.Country Foreign Key linked
to the Country.CountryID Primary Key. The DisplayMember is Country, and
the ValueMember is Country. Under (DataBindings), the SelectedValue is
customerBindingSource.

However, even with the above setup, which so far as I can tell is
correct, the combobox displays as blank. Nothing is displayed, and
nothing is selectable.

I can't think of a way to send a copy without posting the complete
solution (which I have replicated in a 1.12MB test solution) as it
doesn't involve any non IDE generated code. Even if I did post the
solution, the Database would still be missing.

Any idea what is going wrong?

Regards,
Wingot

Dec 6 '07 #7

Steven Cheng[MSFT]

Hi Wingot,

Thanks for your reply.

For the further scenario you mentioned, my understand is that you now let
the wingFlexClientDataSet return tree tables(with relations) and then bind
each of them to different dropdownlist (via setting DataMember), but found
the dropdownlist doesn't get populated,correct?

Would you confirm the following things:

** are you purely use datasource control(no extra code) for the databinding

** for the value you set to the dropdownlist's "DataTextField" and
"DataValueField" are set to the correct column field name(in the certain
table in DataSet), these columns should not be any column in other
table(linked by the original table) since ASP.NET databinding does not
support automatically linked multipe table through relation.

You can also try creating a simple aspx page and put the dropdownlist and
datasource control at top level to see whether it can works. If that also
not work, we can first concentrate on such a simplified page.

BTW, I've seen your another new thread posted. Do you think it proper that
we continue discuss here or in that one?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

>In-Reply-To: <9n**************@TK2MSFTNGHUB02.phx.gbl>
Subject: Re: DropDown Boxes for data entry of fixed fields
Date: Thu, 6 Dec 2007 22:39:34 +0900

Hey,

I have attempted to add another BindingSource, for Country. The
DataMember is Country, DataSource is wingFlexClientDataSet. This is the
same DataSet that is being used for the customerBindingSource that
works. wingFlexClientDataSet is a DataSet that includes the complete
Client Schema, which includes Customer, Country, and MedicalCondition.

When I then set up a Data Binding for the DataSource
FK_Customer_Country, which has the Customer.Country Foreign Key linked
to the Country.CountryID Primary Key. The DisplayMember is Country, and
the ValueMember is Country. Under (DataBindings), the SelectedValue is
customerBindingSource.

However, even with the above setup, which so far as I can tell is
correct, the combobox displays as blank. Nothing is displayed, and
nothing is selectable.

I can't think of a way to send a copy without posting the complete
solution (which I have replicated in a 1.12MB test solution) as it
doesn't involve any non IDE generated code. Even if I did post the
solution, the Database would still be missing.

Any idea what is going wrong?

Regards,
Wingot

Dec 7 '07 #8

Steven Cheng[MSFT]

Hi Wingot,

Any progress on this issue?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

>Date: Fri, 07 Dec 2007 06:06:09 GMT
Subject: Re: DropDown Boxes for data entry of fixed fields

Hi Wingot,

Thanks for your reply.

For the further scenario you mentioned, my understand is that you now let
the wingFlexClientDataSet return tree tables(with relations) and then bind
each of them to different dropdownlist (via setting DataMember), but found
the dropdownlist doesn't get populated,correct?

Would you confirm the following things:

** are you purely use datasource control(no extra code) for the databinding

** for the value you set to the dropdownlist's "DataTextField" and
"DataValueField" are set to the correct column field name(in the certain
table in DataSet), these columns should not be any column in other
table(linked by the original table) since ASP.NET databinding does not
support automatically linked multipe table through relation.

You can also try creating a simple aspx page and put the dropdownlist and
datasource control at top level to see whether it can works. If that also
not work, we can first concentrate on such a simplified page.

BTW, I've seen your another new thread posted. Do you think it proper that
we continue discuss here or in that one?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

>>In-Reply-To: <9n**************@TK2MSFTNGHUB02.phx.gbl>
Subject: Re: DropDown Boxes for data entry of fixed fields
Date: Thu, 6 Dec 2007 22:39:34 +0900

Hey,

I have attempted to add another BindingSource, for Country. The
DataMember is Country, DataSource is wingFlexClientDataSet. This is the
same DataSet that is being used for the customerBindingSource that
works. wingFlexClientDataSet is a DataSet that includes the complete
Client Schema, which includes Customer, Country, and MedicalCondition.

When I then set up a Data Binding for the DataSource
FK_Customer_Country, which has the Customer.Country Foreign Key linked
to the Country.CountryID Primary Key. The DisplayMember is Country, and
the ValueMember is Country. Under (DataBindings), the SelectedValue is
customerBindingSource.

However, even with the above setup, which so far as I can tell is
correct, the combobox displays as blank. Nothing is displayed, and
nothing is selectable.

I can't think of a way to send a copy without posting the complete
solution (which I have replicated in a 1.12MB test solution) as it
doesn't involve any non IDE generated code. Even if I did post the
solution, the Database would still be missing.

Any idea what is going wrong?

Regards,
Wingot


Dec 11 '07 #9

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

Similar topics

2 9608

Select multiple items from a dropdown

by: Jas |last post by:

I want an ASP page with a dropdown and a simple button. Every time the user chooses an item from the dropdown and clicks on the button i want that value written below in list and allow user to...

ASP / Active Server Pages

4 1975

error when selecting data from the dropdown list

by: Doslil |last post by:

I have a form which has a subform.In the main form I have only one field (this is a drop down list and has a query attached to it) which selects empno,Name from the EmployeeInformation table. ...

Microsoft Access / VBA

2 1663

Limiting Selections In DropDown List

by: Kathy |last post by:

Scenario: Multiple Divisions. Each Division has multiple Buildings. Each Building has multiple Floors. Each Floor has a Supervisor. Tables: (abbreviated) TblDivision DivisionID Division

Microsoft Access / VBA

2 1782

Disabling text boxes within a data grid whilst in edit mode.

by: Gary |last post by:

Hello All, I have an editable data grid in my web form, this grid allows the user to add new records, edit existing records and also delete them. When a user adds a record the grid goes in to...

ASP.NET

19 3962

Dynamic fill form fields depending on dropdown box

by: Alex |last post by:

Hello list This question has probably already been asked, but let me ask again I have a mysql database to which I connect with my php scripts. The database contains articles. Name, Unit_Price...

PHP

2 2110

Verifying data in dynamically generated text boxes

by: Sethos |last post by:

I am sure that this has been covered, hashed, and rehashed, but a search on the group did not produce the answer, so forgive me if this seems like a "newbie" type question... Besically, I have a...

Javascript

4 3454

Cascading Combo Boxes not seeing info in previous boxes

by: klarae99 |last post by:

Hello, I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields...

Microsoft Access / VBA

3 1705

cant get dropdown list bound to data in template column of gridvie

by: =?Utf-8?B?UGF1bA==?= |last post by:

Hi I have a generic list of data list <typelistcategory; listcategory = new list <type>; I also have a dropdown box that I have put into a template column of a gridview. I was able to populate...

ASP.NET

9 2069

Populat a NewRecord from Text boxes Revisited

by: RICHARD BROMBERG |last post by:

Please bear in mind that I am a newbie. I am posting this question a second time because the responses to my earlier post were a little wide of the mark. So, here goes: I am using Access 2000...

Microsoft Access / VBA

7070

Changing the language in Windows 10

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...

Windows Server

7267

Problem With Comparison Operator <=> in G++

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,...

C / C++

7449

Discussion: How does Zigbee compare with other wireless protocols in smart home applications?

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...

General

5566

AI Job Threat for Devs

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,...

Career Advice

1 4993

Access Europe - Using VBA to create a class based on a table - Wed 1 May

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...

Microsoft Access / VBA

4666

Couldn’t get equations in html when convert word .docx file to html file in C#.

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...

C# / C Sharp

3148

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

1495

transfer the data from one system to another through ip address

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 ...

C# / C Sharp

1 729

How to add payments to a PHP MySQL app.

by: muto222 |last post by:

How can i add a mobile payment intergratation into php mysql website.

PHP

DropDown Boxes for data entry of fixed fields | Bytes (2025)

FAQs

What is the difference between a combobox and a drop-down list? ›

A drop-down list box saves space (it can drop down to cover other dialog box controls temporarily). A combo box allows the user either to select an item from the list or type in a new item.

What is the difference between a listbox and a drop-down list? ›

Summary: Listboxes and dropdowns are compact UI controls that allow users to select options. Listboxes expose options right away and support multi-selection while dropdowns require a click to see options and support only single-selection.

What is the difference between picklist and dropdown? ›

A drop-down list (abbreviated drop-down, or DDL; also known as a drop-down menu, drop menu, pull-down list, picklist) is a graphical control element, similar to a list box, that allows the user to choose one value from a list either by clicking or hovering over the menu.

Are combo boxes also called drop down boxes? ›

The term "combo box" is sometimes used to mean "drop-down list". In both Java and . NET, "combo box" is not a synonym for "drop-down list". Definition of "drop down list" is sometimes clarified with terms such as "non-editable combo box" (or something similar) to distinguish it from "combo box".

How to create an AutoComplete dropdown List in Excel? ›

On the Excel menu, click Preferences. Under Formulas and Lists, click AutoComplete. In the Show options after typing box, enter the number of letters that you want to type before the AutoComplete menu appears.

How do I create a drop-down list in Excel and keep formatting? ›

Select the cell(s) with your drop-down menu. On the Home tab, in the Styles group, click Conditional Formatting > New Rule… . In the New Formatting Rule dialog window, choose the Format only cells that contain option. Choose Specific Text from the first drop-down box and containing from the second drop-down box.

How do I create a fixed position in Excel? ›

From the View tab, Windows Group, click the Freeze Panes drop down arrow. Select either Freeze Top Row or Freeze First Column. Excel inserts a thin line to show you where the frozen pane begins.

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Virgilio Hermann JD

Last Updated:

Views: 6297

Rating: 4 / 5 (61 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Virgilio Hermann JD

Birthday: 1997-12-21

Address: 6946 Schoen Cove, Sipesshire, MO 55944

Phone: +3763365785260

Job: Accounting Engineer

Hobby: Web surfing, Rafting, Dowsing, Stand-up comedy, Ghost hunting, Swimming, Amateur radio

Introduction: My name is Virgilio Hermann JD, I am a fine, gifted, beautiful, encouraging, kind, talented, zealous person who loves writing and wants to share my knowledge and understanding with you.