我在devextreme中使用了datagrid。
如何将数据网格发送到asp.net mvc中的控制器?
在我看来,我已经尝试过:

  @using (Html.BeginForm("action-name", "controller-name", FormMethod.Post))
            {
                <div id="frm"></div>
                <div id="grid"></div>
                <div class="submit-button" id="submitBtn"></div>
            }

这是我的模型:
public class class-name
    {
        public int id { get; set; }
        public string Name { get; set; }
        public string FName { get; set; }
        public ContactInfo ContactInfo { get; set; }
    }

 public class ContactInfo
    {
        public string type { get; set; }
        public string value { get; set; }
    }

在我的contoller中,我得到表单数据(类名),但是网格数据(ContactInfo)为空

最佳答案

您可以为每一列使用一个cellTemplate,并且在cellTemplate中必须使用隐藏输入。例如,假设以下代码:

factory.Add().DataField("Mobile")
             .CellTemplate(@<text>
              <%= text %>
              <input type='hidden' name='Addresses[<%= rowIndex %>].Mobile' value='<%= value %>' />
              </text>);

text,rowIndex,value是DevExtreme对象。
有关更多信息,请查看链接的cellInfo部分。
https://js.devexpress.com/Documentation/ApiReference/UI_Widgets/dxDataGrid/Configuration/columns/?search=columns

10-05 21:06
查看更多