Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2006, 06:30 AM
Registered User
 
Join Date: Apr 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bind two dropdown without autopostback

I have two dropdownlists, the first is populated with a fixed
collection, and the second has no listitems. When the first dropdown
is selected the second one will populate accordingly. Is there a way
that I can have the list items in the second dropdown populate without
using an auto postback? Thank you

 
Old April 20th, 2006, 01:46 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Yes, you will have to use JavaScript, or AJAX.

 
Old April 21st, 2006, 12:08 AM
Registered User
 
Join Date: Apr 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can u please tell me the code using javascript....

 
Old April 21st, 2006, 02:03 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

No I can't. Try posting in a JavaScript forum, the would be better to help you there.

 
Old March 28th, 2007, 04:10 AM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by xs2bharat
 Hi.....this is madhu.....even i am devoloping an asp.net application where i need to populate dropdown upon selecting another dropdown without postbacks.Help me out if this is working for you....
thanks in advance
madhu
k.madhu
 
Old April 11th, 2007, 12:26 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had such a scenario once. I can't give you the code it self because I don't have it :), but concept is simple;

If you are using JavaScript, you need to create an HTML Hidden field, and store the values at it and then copy it back at the second drop down list (or listbox if you where using one).

But I really recommend using AJAX, it's a good practice, and you can find some good free assemblies which can help you, me my self I really like "Anthym" it's very simple yet powerful, anyway with AJAX I don't think you'll have any problem :)


Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
 
Old April 11th, 2007, 07:41 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Hi,

I'm just curious. I use muliple drop-downs extensively in my applications that fire on SelectedIndexChanged. They work soooo fine. I used to do those with Javascript. What a pain! Why can't you tolerate the postback?

Thanks,
Richard

 
Old April 12th, 2007, 01:44 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well it really depends on your application, if it's published on the internet, or if the amount of data posted into the page is relatively huge, I believe you should minimize the amount of data posted from/to the server, and the amount of the server trips too.

But if it's and internal web application, that is published in an internal LAN, well.. yeah I agree, why bother :).

But anyway it's always a good practice to try new stuff, thats why we have choosen this field of studying for after all :D


Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
 
Old April 12th, 2007, 03:13 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

If you don't want to send a lot of data to the client then the javascript solution is the worst since it will send out all of the data at once to the client for all of the options in the first drop-down. In the javascript solution all of the data exists on the page and then is accessed whenever you change the selection in the first drop-down. And it can be extremely messy.

I'll send some example code if you're still interested... and I can still find some of my own since the autopostback and SelectedIndexChange have been a God send for me. However, I have never tried to integrate that javascript into a .NET application.

Richard

 
Old April 15th, 2007, 12:41 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yeah rstelma I agree with the messy part, JavaScript by nature is a very messy scripting language, but when you say:
 "If you don't want to send a lot of data to the client then the JavaScript solution is the worst since it will send out all of the data at once to the client for all of the options in the first drop-down", I really disagree :), although it's true you send some extra script when using a JavaScript, but that this data is sent only when you inquire the page, after that, as you said, all the work is processed on the client machine, while if you used "autoPostBack", every time you do the even (change the index in our case) you'll do a server trip, which is an extra load on the server, specially if you are inquiring a huge amount of data from a database and sending it through the internet, it will be like hell to you customer to wait for the page :)

Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"





Similar Threads
Thread Thread Starter Forum Replies Last Post
can we bind datagrid and dropdown list rakeshgv SQL Server 2000 0 August 21st, 2006 02:13 AM
AJAX and AutoPostBack [email protected] Ajax 0 May 9th, 2006 07:34 AM
Dropdown list without autopostback choudhmh ASP.NET 1.0 and 1.1 Basics 0 December 3rd, 2004 07:29 AM
How to bind data to a dropdown in a datalist thats broushly ASP.NET 1.0 and 1.1 Basics 1 April 28th, 2004 01:52 PM
AutoPostBack stu9820 ASP.NET 1.0 and 1.1 Professional 7 September 9th, 2003 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.