使用jQuery级联下拉 [英] Cascading dropdown using jquery

查看:62
本文介绍了使用jQuery级联下拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
我正在尝试使用jquery级联下拉菜单
我将列出我的代码

1.代码背后的代码:

hello friends
I was trying cascading dropdown using jquery
I will list down my code

1. codebehind code:

[WebMethod]
      public static List<DataRow> getVC(string strGEO)
      {
          try
          {
              List<DataRow> lstVC = new List<DataRow>();
              SqlConnection objCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["SQL"].ConnectionString.ToString());
              SqlCommand objCmd = new SqlCommand("FWB_GetVC", objCon);
              objCon.Open();
              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();
              objDA.Fill(objDT);
              if (objDT.Rows.Count > 0)
              {
                  //lstVC = new List<DataRow>(objDT.Select());
                  lstVC = objDT.Select().ToList();

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



2. aspx代码:



2. aspx code:

<script>
        $(document).ready(function () {

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



我的问题是,我的函数背后的代码是返回列表对象.无法在jquery中访问,因为未调用coz函数loadVC.

任何想法,出了什么问题?
以及如何使用jquery访问列表并将其绑定到下拉列表?

在此先感谢



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

推荐答案

(document).ready(function(){ }); 函数fillVC(){ 尝试 { var value =
(document).ready(function () { }); function fillVC() { try { var value =


(#ddlGEO").val(); alert(value);
("#ddlGEO").val(); alert(value);


.ajax({ 输入:"POST", 网址:"CascadingDropDown_JQuery.aspx/getVC", 数据:"{strGEO:"" +
.ajax({ type: "POST", url: "CascadingDropDown_JQuery.aspx/getVC", data: "{strGEO: ''" +


这篇关于使用jQuery级联下拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆