By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,679 Members | 2,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,679 IT Pros & Developers. It's quick & easy.

DropDown Boxes for data entry of fixed fields

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.