2011-06-22 51 views

回答

0

控制器上使用下面的代碼:

public List<ReceiveType> _data = new List<ReceiveType> { 
       new ReceiveType{ReceiveTypeID=1,ReceiveTypeName= "Purchase Order"}, 
       new ReceiveType{ReceiveTypeID=2,ReceiveTypeName= "Sales Return"}, 
       new ReceiveType{ReceiveTypeID=3,ReceiveTypeName= "FOC"} 
      }; 

public string load_cmbBoxWithServerSideDataFromClient() 
     { 
      var _List = new SelectList(_data, "ReceiveTypeID", "ReceiveTypeName"); 
      return new JavaScriptSerializer().Serialize(_List); 
     } 

上查看頁使用下面的代碼

@(Html.Telerik().ComboBox().Name("cmbLoadServerData")) 
<input type="button" value="load" onclick="load_ServerDataFromClient()" /><br /> 

function load_ServerDataFromClient() { 
     var cmb = $('#cmbLoadServerData').data('tComboBox'); 

     $.get("/Home/load_cmbBoxWithServerSideDataFromClient", function (response) { 

      var selectList = $.parseJSON(response); 
      cmb.dataBind(selectList, true); 
     }); 
    } 
相關問題