Efficient way to display a dropdown description value when only the key is in the result set

J

JLeary

Hi all,

I have a results set with a column ( project_id ) which is associated with a
dropdown in datagrid edit mode. When not in edit mode, I also want to
display the description for this value. I know I can add a join to my Select
statement, but that really isn't too efficient for multiple columns like
this. Since I am already creating a datasource for the dropdown, would it
make sense just to cross-reference that source and change the display in
ItemDataBound? I know there are multiple ways to do this, I just want to do
it the most efficient.

Thanks in advance.
 
Y

Yan-Hong Huang[MSFT]

Hello,

If you want to bind different controls to a sa me datasource(for examle look up the ID from the Tires table for columns
LeftTire and RightTire in table Cars) the both of the ComboBoxes will get the same CurrencyManager (this.BindingContext
[dataset.Tires]). So when you change one of the ComboBoxes then both of them will change. To avoid that you have two
options:

1. Use different BindingContextes.
leftTireCombo.BindingContext = new BindingContext();
rightTireCombo.BindingContext = new BindingContext();
The problem is that you will not be able to bind the two ComboBoxes to the same position in Cars since they will get different
CurrencyManagers in table Cars too.

2. Bind to different DataViews.
leftTireCombo.DataSource = new DataView(dataset.Tires);
rightTireCombo.DataSource = new DataView(dataset.Tires);

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "JLeary" <[email protected]>
!Subject: Efficient way to display a dropdown description value when only the key is in the result set
!Date: Thu, 31 Jul 2003 15:59:30 -0400
!Lines: 16
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <#[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!NNTP-Posting-Host: host-216-57-145-64.customer.veroxity.net 216.57.145.64
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridcontrol:5958
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!
!Hi all,
!
!I have a results set with a column ( project_id ) which is associated with a
!dropdown in datagrid edit mode. When not in edit mode, I also want to
!display the description for this value. I know I can add a join to my Select
!statement, but that really isn't too efficient for multiple columns like
!this. Since I am already creating a datasource for the dropdown, would it
!make sense just to cross-reference that source and change the display in
!ItemDataBound? I know there are multiple ways to do this, I just want to do
!it the most efficient.
!
!Thanks in advance.
!
!
!
!
!
 
J

JLeary

I accomplished what I needed by just adding a label with the descriptive
field of the datasource I was using to populate my dropdown in edit mode. In
non-edit mode, I display the label and in edit mode the dropdown. Both are
populated/defined by the same datasource.

Yan-Hong Huang said:
Hello,

If you want to bind different controls to a sa me datasource(for examle
look up the ID from the Tires table for columns
LeftTire and RightTire in table Cars) the both of the ComboBoxes will get
the same CurrencyManager (this.BindingContext
[dataset.Tires]). So when you change one of the ComboBoxes then both of
them will change. To avoid that you have two
options:

1. Use different BindingContextes.
leftTireCombo.BindingContext = new BindingContext();
rightTireCombo.BindingContext = new BindingContext();
The problem is that you will not be able to bind the two ComboBoxes to the
same position in Cars since they will get different
 
Y

Yan-Hong Huang[MSFT]

Hello,

If the data consumer doesn't move forward or backward the data pointer, a single datasource is enough. However, if the
position is changed, we need to use the way that I introduced to make sure that each data is independent.

Thanks.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "JLeary" <[email protected]>
!References: <#[email protected]> <[email protected]>
!Subject: Re: Efficient way to display a dropdown description value when only the key is in the result set
!Date: Tue, 5 Aug 2003 16:58:27 -0400
!Lines: 81
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!NNTP-Posting-Host: host-216-57-145-64.customer.veroxity.net 216.57.145.64
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridcontrol:6019
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!
!
!I accomplished what I needed by just adding a label with the descriptive
!field of the datasource I was using to populate my dropdown in edit mode. In
!non-edit mode, I display the label and in edit mode the dropdown. Both are
!populated/defined by the same datasource.
!
!!> Hello,
!>
!> If you want to bind different controls to a sa me datasource(for examle
!look up the ID from the Tires table for columns
!> LeftTire and RightTire in table Cars) the both of the ComboBoxes will get
!the same CurrencyManager (this.BindingContext
!> [dataset.Tires]). So when you change one of the ComboBoxes then both of
!them will change. To avoid that you have two
!> options:
!>
!> 1. Use different BindingContextes.
!> leftTireCombo.BindingContext = new BindingContext();
!> rightTireCombo.BindingContext = new BindingContext();
!> The problem is that you will not be able to bind the two ComboBoxes to the
!same position in Cars since they will get different
!> CurrencyManagers in table Cars too.
!>
!> 2. Bind to different DataViews.
!> leftTireCombo.DataSource = new DataView(dataset.Tires);
!> rightTireCombo.DataSource = new DataView(dataset.Tires);
!>
!> Hope that helps.
!>
!> Best regards,
!> Yanhong Huang
!> Microsoft Online Partner Support
!>
!> Get Secure! - www.microsoft.com/security
!> This posting is provided "AS IS" with no warranties, and confers no
!rights.
!>
!> --------------------
!> !From: "JLeary" <[email protected]>
!> !Subject: Efficient way to display a dropdown description value when only
!the key is in the result set
!> !Date: Thu, 31 Jul 2003 15:59:30 -0400
!> !Lines: 16
!> !X-Priority: 3
!> !X-MSMail-Priority: Normal
!> !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!> !X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!> !Message-ID: <#[email protected]>
!> !Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!> !NNTP-Posting-Host: host-216-57-145-64.customer.veroxity.net 216.57.145.64
!> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
!> !Xref: cpmsftngxa06.phx.gbl
!microsoft.public.dotnet.framework.aspnet.datagridcontrol:5958
!> !X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!> !
!> !Hi all,
!> !
!> !I have a results set with a column ( project_id ) which is associated
!with a
!> !dropdown in datagrid edit mode. When not in edit mode, I also want to
!> !display the description for this value. I know I can add a join to my
!Select
!> !statement, but that really isn't too efficient for multiple columns like
!> !this. Since I am already creating a datasource for the dropdown, would it
!> !make sense just to cross-reference that source and change the display in
!> !ItemDataBound? I know there are multiple ways to do this, I just want to
!do
!> !it the most efficient.
!> !
!> !Thanks in advance.
!> !
!> !
!> !
!> !
!> !
!>
!>
!
!
!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top