Я использую asp. net core и bootstrap, я пытаюсь обновить свою таблицу, когда я устанавливаю и снимаю флажки. Проблема в том, что когда я нажимаю кнопку «Сохранить», чтобы обновить таблицу, я хочу получить всю информацию, но когда я пытаюсь это сделать, мой IList<OutputAccessRights> userAccessRights
возвращает счетчик = 0. Как я могу отправить обратно, не потеряв все? Можно ли использовать jquery, javascript?
.cs:
public IActionResult OnPost(int id, string groupAccessName, bool chkDefaultGroup, IList<OutputAccessRights> userAccessRights, string returnUrl = null)
{
ReturnUrl = returnUrl;
else //Update
{
Security security = new Security();
security.GroupAccessUpdate(BellaMain.GlobalVariable.SystemID, Convert.ToInt16(groupAccessID), groupAccessName, false);
Update(Convert.ToInt16(groupAccessID), userAccessRights);
GroupAccessID = id;
GroupAccessName = groupAccessName;
return RedirectToAction("Group AccessDetails", "Form", new { id = GroupAccessID, searchString = SearchString, searchInt = SearchInt }).WithSuccess("Success!", "Updated item!");
}
return Page();
}
Модель:
public class GroupAccessDetailsModel : PageModel
{
private readonly ILogger<GroupAccessDetailsModel> _logger;
public GroupAccessDetailsModel(ILogger<GroupAccessDetailsModel> logger)
{
_logger = logger;
}
public class OutputAccessRights
{
public byte MainMenuID { get; set; }
public byte SubMenuID { get; set; }
public byte OperationID { get; set; }
public string MainMenuDescription { get; set; }
public string SubMenuDescription { get; set; }
public string Operation { get; set; }
public bool ChkUserAccessRights { get; set; }
public bool ChkAddRight { get; set; }
public bool ChkUpdateRight { get; set; }
public bool ChkDelete { get; set; }
public bool FlagDefaultGroupAlreadySet { get; set; }
}
[BindProperty]
public IList<OutputAccessRights> UsersAccessRights { get; set; }
}
html:
@if (Model.UsersAccessRights != null)
{
<table class="table table-striped table-bordered dataTable tableAccessRights" name="userAccessRights" id="userAccessRights" style="width:100%">
<thead>
<tr>
<th>
MainMenu
</th>
<th>
SubMenu
</th>
<th>
Operation
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.UsersAccessRights)
{
<tr>
<td>
@if (Model.GroupAccessID == 0)
{
<input type="checkbox" class="form-check-inline" name="@item.ChkUserAccessRights" id="chkUserAccessRights" asp-for="@item.ChkUserAccessRights" />
@Html.DisplayFor(modelItem => item.MainMenuDescription)
}
else
{
@if (Model.Details != true)
{
<input type="checkbox" class="form-check-inline" name="@item.ChkUserAccessRights" id="chkUserAccessRights" asp-for="@item.ChkUserAccessRights" />
@Html.DisplayFor(modelItem => item.MainMenuDescription)
<span class="text-danger"></span>
}
else
{
<input type="checkbox" class="form-check-inline" name="@item.ChkUserAccessRights" id="chkUserAccessRights" disabled readonly="readonly" />
@Html.DisplayFor(modelItem => item.MainMenuDescription)
}
}
</td>
<td>
@Html.DisplayFor(modelItem => item.SubMenuDescription)
</td>
<td>
@if (Model.GroupAccessID == 0)
{
<input type="checkbox" class="form-check-inline" name="@item.ChkAddRight" id="chkAddRight" asp-for="@item.ChkAddRight" />
<label for="chkAddRight">Insert</label>
}
else
{
@if (Model.Details != true)
{
<input type="checkbox" class="form-check-inline" name="@item.ChkAddRight" id="chkAddRight" asp-for="@item.ChkAddRight" />
<label for="chkAddRight">Insert</label>
<span class="text-danger"></span>
}
else
{
<input type="checkbox" class="form-check-inline" name="@item.ChkAddRight" id="chkAddRight" disabled readonly="readonly" asp-for="@item.ChkAddRight" />
<label for="chkAddRight">Insert</label>
}
}
@if (Model.GroupAccessID == 0)
{
<input type="checkbox" class="form-check-inline" name="@item.ChkDelete" id="chkDelete" asp-for="@item.ChkDelete" />
<label for="chkDelete">Delete</label>
}
else
{
@if (Model.Details != true)
{
<input type="checkbox" class="form-check-inline" name="@item.ChkDelete" id="chkDelete" asp-for="@item.ChkDelete" />
<label for="chkDelete">Delete</label>
<span class="text-danger"></span>
}
else
{
<input type="checkbox" class="form-check-inline" name="@item.ChkDelete" id="chkDelete" disabled readonly="readonly" asp-for="@item.ChkDelete" />
<label for="chkDelete">Delete</label>
}
}
@if (Model.GroupAccessID == 0)
{
<input type="checkbox" class="form-check-inline" name="@item.ChkUpdateRight" id="chkUpdateRight" asp-for="@item.ChkUpdateRight" />
<label for="chkUpdateRight">Update</label>
}
else
{
@if (Model.Details != true)
{
<input type="checkbox" class="form-check-inline" name="@item.ChkUpdateRight" id="chkUpdateRight" asp-for="@item.ChkUpdateRight" />
<label for="chkUpdateRight">Update</label>
<span class="text-danger"></span>
}
else
{
<input type="checkbox" class="form-check-inline" name="@item.ChkUpdateRight" id="chkUpdateRight" disabled readonly="readonly" asp-for="@item.ChkUpdateRight" />
<label for="chkUpdateRight">Update</label>
}
}
</td>
</tr>
}
</tbody>
</table><button type="submit" class="btn btn-primary" asp-page="Group AccessDetails" asp-route-userAccessRights="@Model.UsersAccessRights">@Localizer["Save"]</button>
}