Click here to Skip to main content
12,552,460 members (42,943 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript SQL
Hello everyone,

I am making a website in which there are 15 static dropdownlist whose data are same, and the data are fetched from sql database. Now when i bind these dropdownlist with data in code behind i have to write a method which defines individual name of dropdownlist and then i bind it to data or else i need a method which will scan each and every controls on page and then it will select dropdownlist and then it will bind the data to it..but it is not a proper way , can any one please help me in doing it with javascript.. like i select data with query in code behind and then pass that data to javascript and it finds all the dropdownlist with its Type method and bind the data with it..

Please help me out ...i am really stuck up..

Krunal panchal
Posted 16-Jul-12 4:04am
armagedescu 16-Jul-12 10:29am
I don't see how this is related to C++

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


So you have 15 dropdown's and all DataSource are same right...

Fetch Data One and Store it in a DataTable and Then Bind all Dropdown's with same DataTable.

In this way you can reduce fetching time of your application.

you can loop each control and Check their type and Bind DataSource if required.

foreach (Control c in Page.Controls)
            foreach (Control childc in c.Controls)
                if (childc is ComboBox)
                    childc.DataSource=[Your DataSource]

Other way

you can do it in javascript but in each term you have to fetch data once from your DB
if you dont have any caching mechanization. So why we will go for java script we will do in our code behind.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.161021.1 | Last Updated 13 Oct 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100