0
I’m developing a screen in Aspnet Mvc where I have an index screen that has a model called Parametrizacaovm and on that screen I have a partialView that displays the drives (which is a List<Unidades>
that is contained in the parametric modelVM)
Call from the Parialview:
@Html.Partial("GridMvc", Model.ListaUnidades)
when do a Ubmit in the parent form(Index) the information regarding the list of units does not arrive in the controller, it is null and when I tried to put the attribute @Html.HiddenFor(m => m.ListaUnidades)
in index, in controller the list arrives zeroed.
Someone knows how to solve this problem, so that when performing a Submit in the form he considers the list that is in partialview?
Index:
@using (Ajax.BeginForm(@acao, "Parametrizacao", @ajaxOptions, new { @id = "FormCadastroParametrizacao" }))
{
@Html.HiddenFor(m => m.IdCliente)
@Html.HiddenFor(m => m.RazaoSocialOperadora)
@Html.HiddenFor(m => m.SiglaContrato)
@Html.HiddenFor(m => m.CodigoContrato)
@Html.HiddenFor(m => m.Cadastrar)
@Html.HiddenFor(m => m.ListaUnidades)
<form>
//Outros campos dessa tela....
@Html.Partial("GridMvc", Model.ListaUnidades)
<input type="submit" id="btnSalvar" value="Salvar" class="btn btn-salvar" />
</form>
}
Partialview
@model IEnumerable<Fleury.NovoVAEL.Entidades.Model.Unidade>
@using GridMvc.Html
@{
ViewBag.Title = "GridMvc";
}
<script src="~/Scripts/ScriptsParametrizacao/PaginacaoGridMvc.js"></script>
<script src="~/Scripts/gridmvc.min.js"></script>
<script src="~/Scripts/gridmvc-ext.js"></script>
<link href="~/Content/GridCustomizada.css" rel="stylesheet" />
<div id="results">
<b>Selecione as Unidades</b><div class="code-cut">
@Html.Grid(Model).Columns(Columns =>
{
Columns.Add(c => c.Selecionado)
.Encoded(false)
.Sanitized(false)
.Filterable(true)
.SetWidth(30)
.RenderValueAs(o => Html.CheckBox(o.Codigo.ToString(), o.Selecionado));
Columns.Add(c => c.IdUnidadeSAP).Titled("ID Unidade SAP").Filterable(true);
Columns.Add(c => c.Codigo).Titled("ID Unidade Legado").Filterable(true);
Columns.Add(c => c.Descricao).Titled("Desc. Unidade").Filterable(true);
Columns.Add(c => c.CodPrestadorSAP).Titled("Cod. Prestador SAP").Filterable(true);
Columns.Add(c => c.CodPrestadorVAEL)
.Titled("Cod. Prestador VAEL")
.Filterable(true)
.Encoded(false)
.Sanitized(false)
.SetWidth(30)
.RenderValueAs(c => Html.TextBox(c.Codigo.ToString(), c.CodPrestadorVAEL, new { @class = "form-control" }));
}).WithPaging(10).Sortable(true).WithMultipleFilters()
</div>
</div>
You can put full view code together with partial view and controller
– Netinho Santos
@Netinhosantos added the partial code
– Jhonatas Silva
Remove this <form> right after @Html.Hiddenfor(m => m.List units)
– Netinho Santos
I removed but I still have the same problem
– Jhonatas Silva