页面加载时用
<%SelectList categories = ViewData["CMB1"] as SelectList; %>
 <%=Html.DropDownList("cmb1", categories, "(空)")%>
 这种方法绑定 
在cmb1的change()事件中我用 .ajax提交cmb1的value 然后根据后台查到的数据再绑定cmb2 
可是cmb2没法重新加载绑定数据 
求一个实现联动的方案 在线等 

解决方案 »

  1.   

    jquery 给cmb2赋值。 $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#cmb2"));
      

  2.   

                $("#cmb1").change(function () {
                    var cmb1= $("#cmb1").val();
                    $.ajax({
                        type: "POST",
                        url: "/Nestle/t_service_Order/SelectInit",
                        data: "cmb1=" + cmb1+ "",
                        success: function (result) {
     $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#cmb2"));                      }
                     });
                });
      不知道这么写可不可以? 现在提示脚本错误,对象不支持此属性或方法。
      

  3.   

    后台为
      string cmb1 = Request["cmb1"];
      IList<Ecreate.Model.tfarmerinf> List = Ecreate.Data.Core.DaoFactory.getDao().ExecuteQueryForList<Ecreate.Model.tfarmerinf>("tfarmerinf_SelectByStationId", cmb1);
      ViewData["CMB2"] = new SelectList(List , "id", "name");
     return View("Index");  该怎么写才能实现呢 纠结中 
      

  4.   

      返回json更易操作
    后台 List<SelectListItem> items = new List<SelectListItem>();
                        foreach (var item in cabinInfoList)
                            items.Add(new SelectListItem { Text = " Y" , Value = "" });
         return Json(items, JsonRequestBehavior.AllowGet);前台
     $.getJSON("/Nestle/t_service_Order/SelectInit", { 'cmb1':cmb1}, function(data) {
                $.each(data, function(i, item) {
                     $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#cmb2"));
    });});
      

  5.   

    是第二个list的选项值根据第一个选项值的改变而改变吗?