Post back Form Submit Only Submits Data From First Page

28 Views Asked by At

I have a form which consists of a datatable, I need to submit only the data from the current page from pagination. When I submit the form from first page the data is correctly sent to the controller but when I submit from other pages the data is not sent

CSHTML code

<form method="post" asp-controller="@controller" asp-action="@saveAction">
  <div id="panel-10" class="panel">
    <div class="panel-toolbar">
      <div class="button-container" style="margin: 10px">
        <button type="submit" class="btn btn-success">Update</button>
      </div>
    </div>
    <div class="panel-container show">
      <div class="panel-content">
        <div class="frame-wrap">
          <table id="translations-table" class="table table-bordered table-hover m-0">
            <thead class="thead-themed">
              <tr>
                <th>@type Name</th>
                @foreach (var language in languages.AvailableLanguages) {
                <th>@language</th>
                }
              </tr>
            </thead>
            <tbody>
              else { @for(int i = 0; i < Model.Count; i++) {
              <tr>
                @{ string displayId = Regex.Replace(Model[i].OId, @"[^a-zA-Z0-9]", ""); }
                <td>
                  @Html.HiddenFor(modelItem => Model[i].SId, new { @id = $"s-id-{Model[i].SId}" })
                  @Html.HiddenFor(modelItem => Model[i].OId, new { @id = $"o-id-{Model[i].OId}" })
                  @Html.HiddenFor(modelItem => Model[i].OName, new { @id =
                  $"o-name-{Model[i].OName}" }) @Html.DisplayFor(modelItem => Model[i].OName)
                  <span style="color: #808080; font-size: 10px"
                    >(@Html.DisplayFor(modelItem => Model[i].OId))</span
                  >
                </td>
                @for (int j = 0; j < languages.Languages.Count; j++) { var tr =
                Model[i].Tr?.FirstOrDefault(t => t.C == languages.Languages[j]); if (tr != null) {
                <td>
                  @Html.HiddenFor(modelItem => Model[i].Tr[j].C, new { @id =
                  $"hidden-{Model[i].SId}-{displayId}-{Model[i].Tr[j].C}" })
                  @Html.TextBox($"[{i}].Tr[{j}].TrValue", tr.TrValue, new { @class = "form-control",
                  @id = $"{Model[i].SId}-{displayId}-{tr.C}" ,@onchange = $"onChange();" })
                </td>
                } else {
                <td></td>
                } }
              </tr>
              } }
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</form>

0

There are 0 best solutions below