473,378 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to synchronize multiple drop down lists?

Hi there
ASP.NET 2.0 VB & SQL Express

Lest take Northwind Categories Products as example

I create a table that hold these two together
and I create a stored procedure like
select ProductID, ProductName, CategoryID, from tblCategoryProducts
Where (CategoryID = @CategoryID)

and (in asp.net page) the where control I set to cboCategory.CategoryID

every thing works fine for the first time when you choose category it will
populate correctly the cboProducts
But it stuck on the first attempt when you chosse another category it won't
change the cboProducts

My question is how synchronize the Products CBO base on Caregory cbo on real
time changes
P.S it works fine with MS Access northwind database

Thanks,
Ed Dror
Andrew Lauren
Sep 7 '06 #1
8 7543
Hi Andrew,

After reading throught your post, I'm not quite clear on some points. Would
you please help me on these points:
1) Are you using ASP.NET Data Source controls such as ObjectDataSource or
SqlDataSource?
2) Would you please post some code such as how you associate the two
DropDownList? A complete working project is better, though.

If you are using Data Source controls, they can bind some parameter to a
control's property; thus when the control's property is changed on
postback, the Data Source control will automatically get updated data. Then
you bind your second DropDownList to the Data Source control.

I'm looking forward to your update so that we can continue further
discussion. Thank you.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 8 '06 #2
Walter,

I'm using sqlDataSource

Base on MS Dynamics SL I extracted the Modules (75) and Screens (1300)
Then I create one (Module) to Many (Screens) relationship
Then I create a table ModulesScreens looks like this

ModuleID, ModuleCode, ModuleName, ScreenID, ScreenName, ScreenNumber,
ScreenType

Now in WebDev Express asp.net I created one Drop Down list base on
sqlDatasource Modules tabls
Object Name = ModuleName + enable auto post back

Then I created Drop Down list base on Stored Procedure look like this
Object Name = ScreenNumber
set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

GO

ALTER PROCEDURE [dbo].[usp_SelectScreen]

@ModuleName varchar(50)

AS

SELECT ModuleName, ScreenName, ScreenNumber, ScreenType, ScreenID

FROM ScreensModules WHERE (ModuleName = @ModuleName)

ORDER BY ScreenName

With the WHERE = Control
ControlID = ModuleName (this is the Modules drop down list)
Value = ModuleName.SelectedValue

When you run this page it working for the first open drop down list

I'm picking General Ledger from Modules drop down and the second module show
all the screens
That belong to this module but when I pick another module name the second
drop down did not refresh
It stuck with the first pick from the drop down
Its very very similar to MS KB #289670 with Access database

I hope you will get the picture now and tell me how can I refresh the second
drop down list?

I also created a function that will call the stored procedure with passing
parameter from the Module drop down list
And (function call mySelectScreen)
Protected Sub ScreenName_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ScreenName.SelectedIndexChanged

Call mySelectScreen()

End Sub

but with no succsess

Thanks,

Ed

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:ie*************@TK2MSFTNGXA01.phx.gbl...
Hi Andrew,

After reading throught your post, I'm not quite clear on some points.
Would
you please help me on these points:
1) Are you using ASP.NET Data Source controls such as ObjectDataSource or
SqlDataSource?
2) Would you please post some code such as how you associate the two
DropDownList? A complete working project is better, though.

If you are using Data Source controls, they can bind some parameter to a
control's property; thus when the control's property is changed on
postback, the Data Source control will automatically get updated data.
Then
you bind your second DropDownList to the Data Source control.

I'm looking forward to your update so that we can continue further
discussion. Thank you.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 8 '06 #3
Hi Ed,

Here're some steps I'm using to test the functionality:
1) Create a table Modules:

create table Modules(ModuleName varchar(50) not null)

2) Create a table ModuleScreens:

create table ModuleScreens(ModuleName varchar(50) not null, ScreenName
varchar(50) not null)

3) Insert some test data:

insert into Modules values('module1')
insert into Modules values('module2')
insert into ModuleScreens values('module1', 'screen1')
insert into ModuleScreens values('module2', 'screen2')

4) Create the stored procedure:

create procedure spGetScreenByModuleName
@ModuleName varchar(50)
as
select ScreenName from ModuleScreens
where ModuleName=@ModuleName

5) In web application, create a new WebForm, add first DropDownList,
configure it to use SqlDataSource to use SQL:

select ModuleName from Modules

and configure its Text and Value both to use the ModuleName field. Also
set its AutoPostBack = true.

6) Add another DropDownList, configure it to use a new SqlDataSource which
is configured to use the stored procedure; configure its parameter to use
control parameter and use first DropDownList's SelectedValue.

7) Run this WebForm, change selection of first DropDownList, you will see
the second DropDownList's values changes accordingly.

I hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 12 '06 #4
Walter,

I did all that and it change but only for the first time
Like when you choose General Ledger module you will see the
Screen name drop down list with the general Ledger screens - ok

Now if you change the Module again like AR the ScreenName dropdown don't
change
It stay with the first time
All I want to change it all the time when you switch modules the screens
names will change too
How to make it like Refresh or Require like ms access without refreshing all
the page or
something when module text change then something happened

Ed,

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:8l**************@TK2MSFTNGXA01.phx.gbl...
Hi Ed,

Here're some steps I'm using to test the functionality:
1) Create a table Modules:

create table Modules(ModuleName varchar(50) not null)

2) Create a table ModuleScreens:

create table ModuleScreens(ModuleName varchar(50) not null, ScreenName
varchar(50) not null)

3) Insert some test data:

insert into Modules values('module1')
insert into Modules values('module2')
insert into ModuleScreens values('module1', 'screen1')
insert into ModuleScreens values('module2', 'screen2')

4) Create the stored procedure:

create procedure spGetScreenByModuleName
@ModuleName varchar(50)
as
select ScreenName from ModuleScreens
where ModuleName=@ModuleName

5) In web application, create a new WebForm, add first DropDownList,
configure it to use SqlDataSource to use SQL:

select ModuleName from Modules

and configure its Text and Value both to use the ModuleName field. Also
set its AutoPostBack = true.

6) Add another DropDownList, configure it to use a new SqlDataSource which
is configured to use the stored procedure; configure its parameter to use
control parameter and use first DropDownList's SelectedValue.

7) Run this WebForm, change selection of first DropDownList, you will see
the second DropDownList's values changes accordingly.

I hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 12 '06 #5
Hi Ed,

I understand that in your project it doesn't work as expected. Since I
don't have your project at hand, I had to use a simpler test project to
test the issue.

As I described in my last reply, the simple test works correctly. Would you
please try the steps in my last reply and see if it works or not?

If the simple test works, maybe you can compare it with your current
project and see which difference is causing the problem.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 12 '06 #6
Walter,

I did exactly what you have told me to do
Yes it works for the first time only
When I go back to the Module dropdown list and change it
The screen dropdown remain the same nothing change (it contain the first
module screen names)

Do you have a client side script that will reset the second dropdown list?
Because ASP.NET is the server side not a client side it won't change
We need to built a DLL to do this job?
Thanks,
Ed Dror

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:pp**************@TK2MSFTNGXA01.phx.gbl...
Hi Ed,

I understand that in your project it doesn't work as expected. Since I
don't have your project at hand, I had to use a simpler test project to
test the issue.

As I described in my last reply, the simple test works correctly. Would
you
please try the steps in my last reply and see if it works or not?

If the simple test works, maybe you can compare it with your current
project and see which difference is causing the problem.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 12 '06 #7
Hi Ed,

Sorry for misunderstanding your previous reply. So let's do a summary so
far:

======
Using the simplest scenario as I described in my reply, when you click the
first DropDownList to select second item, the second DropDownList doesn't
show "screen2", right?
======

This is strange. Please help me on following questions so that we can go
further:
1) Is the WebForm actually performing a postback when you change the
selected item in first DropDownList? Since we've set its AutoPostBack=true,
it should.
2) Is javascript enabled in your web browser? Javascript is required to do
the postback correctly.

Also, would you please handle the second SqlDataSource's Selecting event by:

protected void SqlDataSource2_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
Response.Write(e.Command.Parameters[0].Value);
}

This will output the actual parameter value passed to the stored procedure.
When you change the first DropDownList's selected item, it should correctly
output the value.

Also, I've including my page source here for your reference:
======
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwULLTE5NjE4MzgxODYPZBYCAgMPZBYGAgEPEA8WAh4LXyF EYXRhQm91bmRnZBAVA
gdtb2R1bGUxB21vZHVsZTIVAgdtb2R1bGUxB21vZHVsZTIUKwM CZ2dkZAIEDxAPFgIfAGdkEBUBB
3NjcmVlbjIVAQdzY3JlZW4yFCsDAWdkZAIFDw9kDxAWAWYWARY CHg5QYXJhbWV0ZXJWYWx1ZQUHb
W9kdWxlMhYBZmRkZKzAJI0cDOXzO1luqLJf1kXKgrvb" />
</div>

<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>
<div>
<select name="DropDownList1"
onchange="javascript:setTimeout('__doPostBack(\'Dr opDownList1\',\'\')', 0)"
id="DropDownList1">
<option value="module1">module1</option>
<option selected="selected" value="module2">module2</option>

</select>
<select name="DropDownList2" id="DropDownList2">
<option value="screen2">screen2</option>

</select>

</div>

<div>

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEWBQLZ29nUDQKd5I/lCgKp3oX4AwL+mr84AtLI02u6LPTk2Ktx6jNq5AmDyvW71BVhr
A==" />
</div></form>
</body>
</html>
======

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 13 '06 #8
Walter,

Please take a look at Microsoft KB Article # 289670 How to synchronize two
combo boxes on a form in Access 2002/3

Let's take the Northwind database for example

All I want is to display two dropdown lists one for categories and one for
product

When user picks a category the products that belong to that category should
be display

When the user change category the product dropdown list must change also
based on category

And then submit this into a table

As of today we can't translate this article 289670 into ASP.NET 2.0

If you can show me how I will be very please (lets use the Northwind
database)

As of now I gave up on that I let the user's type instead of picking from
dropdown lists

Which eliminate typing errors?

(I have hundreds of users that using Microsoft Dynamics SL and it is very
time consuming)

Maybe Atlas will solved this issue

Thanks,

Ed Dror

Andrew Lauren

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:to**************@TK2MSFTNGXA01.phx.gbl...
Hi Ed,

Sorry for misunderstanding your previous reply. So let's do a summary so
far:

======
Using the simplest scenario as I described in my reply, when you click the
first DropDownList to select second item, the second DropDownList doesn't
show "screen2", right?
======

This is strange. Please help me on following questions so that we can go
further:
1) Is the WebForm actually performing a postback when you change the
selected item in first DropDownList? Since we've set its
AutoPostBack=true,
it should.
2) Is javascript enabled in your web browser? Javascript is required to do
the postback correctly.

Also, would you please handle the second SqlDataSource's Selecting event
by:

protected void SqlDataSource2_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
Response.Write(e.Command.Parameters[0].Value);
}

This will output the actual parameter value passed to the stored
procedure.
When you change the first DropDownList's selected item, it should
correctly
output the value.

Also, I've including my page source here for your reference:
======
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value=""
/>
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwULLTE5NjE4MzgxODYPZBYCAgMPZBYGAgEPEA8WAh4LXyF EYXRhQm91bmRnZBAVA
gdtb2R1bGUxB21vZHVsZTIVAgdtb2R1bGUxB21vZHVsZTIUKwM CZ2dkZAIEDxAPFgIfAGdkEBUBB
3NjcmVlbjIVAQdzY3JlZW4yFCsDAWdkZAIFDw9kDxAWAWYWARY CHg5QYXJhbWV0ZXJWYWx1ZQUHb
W9kdWxlMhYBZmRkZKzAJI0cDOXzO1luqLJf1kXKgrvb" />
</div>

<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>
<div>
<select name="DropDownList1"
onchange="javascript:setTimeout('__doPostBack(\'Dr opDownList1\',\'\')',
0)"
id="DropDownList1">
<option value="module1">module1</option>
<option selected="selected" value="module2">module2</option>

</select>
<select name="DropDownList2" id="DropDownList2">
<option value="screen2">screen2</option>

</select>

</div>

<div>

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEWBQLZ29nUDQKd5I/lCgKp3oX4AwL+mr84AtLI02u6LPTk2Ktx6jNq5AmDyvW71BVhr
A==" />
</div></form>
</body>
</html>
======

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 15 '06 #9

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

Similar topics

1
by: Aaron Prohaska | last post by:
I'm having the problem with this drop down list on postback. For some reason both the ListItems get selected when I change the selected item. Using the code below I'm building the drop down list in...
3
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists. Each group of Drop Down Lists include 3 Drop Down Lists for date such as: DAY, MONTH, and YEAR. I don't want...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
2
by: macyp | last post by:
I have to pass values from one aspx page to another. The controls I have in the first page are: a textbox, 3 drop down lists, and 2 check boxes, and a submit button. It is a search page, and the...
2
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
3
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the...
6
by: Igor | last post by:
Hello I have the following problem. I have three drop down lists on my page. They are filled with data from a database. Initially only the first one is enabled. The next one is enebled when...
3
by: jcassan | last post by:
Hello folks. I am new to these forums and have something, which has been stumping me for little while. I am using pspell to spellcheck a scrolling textbox (textarea) containing user input. I...
5
by: bennever | last post by:
Hi, I plan to use drop down lists to populate team results and will use the standard country/state drop down lists as the base code. The question: how can I populate multiple (5) states from...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.