【问题标题】:ASP.NET CORE 3 frombody NULL with Bootstrap Table plugins带有引导表插件的 ASP.NET CORE 3 frombody NULL
【发布时间】:2021-05-20 04:30:18
【问题描述】:

我正在尝试根据引导表中的此示例进行操作 query params。但是我收到的参数总是NULL,即使我在调用后端之前已经设置了它。我预计收到的价值应该是Supplier。谢谢

查看

<table id="supplier-inbox-table" class="table table-bordered table-striped text-center bootstrap-table"
   data-toggle="table"
   data-query-params="InboxTableParams"
   data-url="/AppService/Get_InboxTableData"
   data-method="post"
   data-pagination="true"
   data-side-pagination="server">
<thead class="thead-dark">
    <tr>
        <th data-checkbox="true"></th>
        <th data-field="ID" data-sortable="true">ID No</th>
        <th data-field="Customer" data-sortable="true">Customer</th>
        <th data-field="StoreCode" data-sortable="true">Store Code</th>
    </tr>
</thead>
<script>
function InboxTableParams(params) {
  params.UserType = 'Supplier';

  return params;
}
</script>

控制器

[HttpPost]
public string Get_InboxTableData([FromBody] InboxTableData inboxData)
{
  return inboxData.UserType;
}

型号

public class InboxTableData
{
    public string UserType { get; set; }
}

【问题讨论】:

  • 表格或输入字段中的数据在哪里?
  • 现在我不想显示数据。我只想将参数从视图传递给控制器​​。即使有数据,我的表格也能正确显示,除非传递 UserType 等自定义参数。

标签: asp.net asp.net-core asp.net-core-3.1 asp.net-core-3.0 bootstrap-table


【解决方案1】:

调用Get_InboxTableData时会有三个参数,UserType,offset and limit。所以你可以尝试使用

public class InboxTableData
    {
        public string UserType { get; set; }
        public int limit { get; set; }
        public int offset { get; set; }

    }

结果:

【讨论】:

    猜你喜欢
    • 2020-01-23
    • 1970-01-01
    • 2021-03-11
    • 2018-11-19
    • 1970-01-01
    • 1970-01-01
    • 2014-01-20
    • 1970-01-01
    • 2014-01-03
    相关资源
    最近更新 更多