我已经将剑道下拉列表转换为剑道多选。我想将多个选择的值传递给控制器​​。

下拉列表包含:


D-UDMS-TMA数据管理系统
U-TDMS-SMA管理系统


下面是我的代码:

$("#btnSendFlow").click(function () {

            debugger;

            var FlowData_array = [];

            //var ROLECODE = $("#DDRolecode").val().trim();---For dropdownlist output: "D"
            var ROLECODE = $("#DDRolecode").data("kendoMultiSelect").value();//added by chetan for multiselect output: "D" "U"

            // var MPID = $("#DDRolecode").data("kendoDropDownList").text().split('-');---for dropdownlist output: (3)["D","UDMS","TMA Data Mgmt System"]

            var control = $("#DDRolecode").data("kendoMultiSelect");
            var selectedDataItems = control.dataItems();

            //// create an array that only contains the selected ids
            var MPID = [];
            $(selectedDataItems).each(function () {
                MPID.push(this.Name.split('-')); // you can access any property on your model here
            });
            console.log(MPID);

            //
            output for MPID while debugging:
            (3)["D","UDMS","TMA Data Mgmt System"] which is 0: Array(3)
                                                              0: "D"
                                                              1: "UDMS"
                                                              2: "TMA Data Management Ltd"
                                                              length: 3
            (3)["U","TDMS","SMA Mgmt System"] which is 1: Array(3)
                                                          0: "M"
                                                          1: "BMET"
                                                          2: "Bglobal NHH MOP"
                                                              length: 3

            length:2
            //
        .....
        .....

         MstHeaderData = {
            REG_ID: $("#hfRegid").val(),
            DataFlow_ID: $("#DDDataFlow").val(),
            RoleCode: ROLECODE,//How to to do for the multiselect values.
            //RoleCode: ROLECODE.trim(),//for dropdownlist
           // MPID: MPID[1] //for dropdownlist
            MPID: MPID// How to do for the multiselect values
        }
        }



带注释的行用于Dropdownlist。

我正在将多个(已选择,即Rolecode和MPID)值传递给控制器​​的Headerdetails。

以下是我的Controller调用:

 public ActionResult SaveSendFlowDetails(Temp_Flow_Generation_Item[] SSFD,HeaderDetails HeaderDetails, FormCollection form)
         {
         ....
         .....
         }


类文件:

public class HeaderDetails
          {
        public int REG_ID { get; set; }
        public int DataFlow_ID { get; set; }
        public string RoleCode { get; set; }
        public string MPID { get; set; }
         }

最佳答案

尝试将模型属性MPID更改为:

public string[][] MPID { get; set; }


由于您的数据是字符串数组的字符串数组,也就是字符串矩阵。

10-08 11:21