Retrieve values from Partial View to View Parent

0

I'm developing a screen in AspNet Mvc where I have an index screen that has a model called ParameterizationVM and on that screen I have a partialView that displays the units (which is a List<Unidades> that is contained in the parametrizationVM model)

Calling ParialView:

  @Html.Partial("GridMvc", Model.ListaUnidades)

When a submit in the parent form (Index) the information regarding the list of units does not arrive in the controller, it becomes nullo and when I tried to put the @Html.HiddenFor(m => m.ListaUnidades) attribute in the index, in the controller the list gets zeroed. >

Someone knows how to solve this problem so that when performing a submit in the form it considers the list that is in the 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>
    
asked by anonymous 09.08.2018 / 16:04

0 answers