Click here to Skip to main content
15,748,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends
I was trying cascading dropdown using jquery
I will list down my code

1. codebehind code:
      public static List<DataRow> getVC(string strGEO)
              List<DataRow> lstVC = new List<DataRow>();
              SqlConnection objCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["SQL"].ConnectionString.ToString());
              SqlCommand objCmd = new SqlCommand("FWB_GetVC", objCon);
              objCmd.CommandType = CommandType.StoredProcedure;
              objCmd.Parameters.AddWithValue("@EmployeeID", 8047);
              objCmd.Parameters.AddWithValue("@GEOID", strGEO);
              SqlDataAdapter objDA = new SqlDataAdapter();
              objDA.SelectCommand = objCmd;
              DataTable objDT = new DataTable();
              if (objDT.Rows.Count > 0)
                  //lstVC = new List<DataRow>(objDT.Select());
                  lstVC = objDT.Select().ToList();

                  return lstVC;
          catch (Exception e)
          { throw e; }

2. aspx code:
        $(document).ready(function () {

        function fillVC() {
            try {
                var value = $("#ddlGEO").val();
                    type: "POST",
                    url: "CascadingDropDown_JQuery.aspx/getVC",
                    data: "{strGEO: '" + $('#ddlGEO').val() + "'}",
                    contentType: "application/json; char-set=utf-8",
                    dataType: "json",
                    success: function Success(data) {
            catch (e) {
        function loadVC(data){

My problem is that, my code behind function is returning list object. It is not accessible in jquery, coz function loadVC is not getting called.

Any idea, what is going wrong??
And how can i access the list using jquery and bind it to dropdown??

Thanks in advance
Member 8554473 19-Jul-12 8:06am    
Hello Do you find a solution, I am facing the same problem ?
dhage.prashant01 27-Aug-12 6:00am    
I have returned data in comma separated string format and in jquery I split it and using loop i bind it to the dropdown

hope it helps you out =)

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