Click here to Skip to main content
Rate this: bad
good
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..
 
Regards,
Krunal panchal
Posted 16-Jul-12 4:04am
Comments
armagedescu at 16-Jul-12 10:29am
   
I don't see how this is related to C++

1 solution

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

Solution 1

Hi,
 
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]
                    childc.DataBind();
                }
            }
        }
 

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.
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 6,609
1 Sergey Alexandrovich Kryukov 6,240
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 16 Jul 2012
Copyright © CodeProject, 1999-2014
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