Click here to Skip to main content
15,923,120 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two dropdownlist say ddlCompany and ddlBranch
both of them list item is from database.
Naturally we load Branch item from ddlCompany_selectedIndexChange event
But I want to load the Brach item when i getFocus ddlBranch.
Posted
Comments
vinodkumarnie 1-Apr-13 8:46am    
If you have knowledge of JavaScript or JQuery you can do this..? Do you..?
Md. Mahfujul 3-Apr-13 7:28am    
No

visit this link...
Opening dropdownlist on OnFocus event?[^]
Happy Coding!
:)
 
Share this answer
 
v2
I think you want to bind (not load) data when you focus on ddlBranch... if that is the case...you can add onfocusevent for ddlbranch and bind data to that list in that event
 
Share this answer
 
Comments
Md. Mahfujul 1-Apr-13 7:37am    
I could not found onfocusevent
you can add onmouse over event to the dropdownlist from codebeinhd in Page_Load event like this
<pre lang="c#">  ddlsample.Attributes.Add("onmouseover", "OnDDLFocus();");


Now in JavaScript you can bind data to the dropdownlist like this

JavaScript
var ddlCountries;
      function OnDDLFocus() {
          ddlCountries = document.getElementById("<%=ddlsample.ClientID %>");
          ddlCountries.options.length == 0;
          AddOption("Loading", "0");
          PageMethods.getElemnts(OnSuccess);
      }

      function OnSuccess(response) {
          ddlCountries.options.length = 0;
          AddOption("Please select", "0");
          var availableArray = response;
          for (var i = 0; i < availableArray.length; i++) {
              AddOption(i, availableArray[i]);
          }
      }
      function AddOption(value,text) {
          var option = document.createElement("option");
          option.Text = text; option.Value = value;
          ddlCountries.options.add(option);
          option.innerText = text;
      }


Also refer this link for complete details
http://forums.asp.net/t/1812012.aspx/1[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900