Modal passing data nullo

-1

When writing in my modal the Controller receives Null.

1 - Modal Model

@model WebAutenticado.Models.CAD_DEVP

@{
    Layout = "~/Views/Shared/_LayoutModal.cshtml";
}


@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()

	<h4>Novo Título</h4>

    <div class="form-horizontal">
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            <div class="form-group">
            @Html.LabelFor(model => model.VENC_PARC, "Vencimento", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.VENC_PARC, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.VENC_PARC, "", new { @class = "text-danger" })
            </div>
        </div>
        
                <div class="form-group">
            @Html.LabelFor(model => model.VALOR_PARC, "Valor", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.VALOR_PARC, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.VALOR_PARC, "", new { @class = "text-danger" })
            </div>
        </div>
        
                <div class="form-group">
            @Html.LabelFor(model => model.CODID_PARC, "Título", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.CODID_PARC, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.CODID_PARC, "", new { @class = "text-danger" })
            </div>
        </div>
        
                <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Incluir" class="btn btn-success" />
            </div>
        </div>
    </div>
}

2 - Modal

<!-- Modal de Titulos -->
<div class="modal fade" id="NovoTitulo" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" id="exampleModalLabel">Novo Título</h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<div class="modal-body">
				@{Html.RenderAction("Create", "CadastroContratoParcela", new { CONTRATO_FIN = Model.CONTRATO_FIN });}
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-danger" data-dismiss="modal">Fechar</button>
			</div>
		</div>
	</div>
</div>

3 - Controller

public ActionResult Create([Bind(Include = "CONTRATO_FIN,PARCELA_PARC,TIPO_PARC,PLANO_PARC,COD_STPA,DTENTRADA_PARC,NACORDO_DEVP")] CAD_DEVP cAD_DEVP)
        {
            if (ModelState.IsValid)
            {
                Random random = new Random();

                var QryParcela = from s in db.CAD_DEVP
                                 select s;
                QryParcela = QryParcela.Where(s => s.CONTRATO_FIN == cAD_DEVP.CONTRATO_FIN);

                var Max = QryParcela.Max(x => x.PARCELA_PARC);
                var MaxParcela = Max + 1;

                var Titulo = cAD_DEVP.CODID_PARC + "-" + random.Next().ToString();

                db.CAD_DEVP.Add(cAD_DEVP).TIPO_PARC = "P";
                db.CAD_DEVP.Add(cAD_DEVP).COD_STPA = 0;
                db.CAD_DEVP.Add(cAD_DEVP).DTENTRADA_PARC = DateTime.Now;
                db.CAD_DEVP.Add(cAD_DEVP).PARCELA_PARC = MaxParcela;
                db.CAD_DEVP.Add(cAD_DEVP).PLANO_PARC = MaxParcela;
                db.CAD_DEVP.Add(cAD_DEVP).CODID_PARC = Titulo;
                db.CAD_DEVP.Add(cAD_DEVP);

                db.SaveChanges();

            }


            return RedirectToAction("Details", "CadastroContrato", new { id = cAD_DEVP.CONTRATO_FIN });
        }

4 - Filled

5-Debug

The VALUE_PARC and VENC_PARC fields are null!

    
asked by anonymous 14.08.2017 / 01:16

1 answer

0

Failed to add fields VALOR_PARC and VENC_PARC in the bind of your template

public ActionResult Create([Bind(Include = "CONTRATO_FIN,PARCELA_PARC,TIPO_PARC,
        PLANO_PARC,COD_STPA,DTENTRADA_PARC,NACORDO_DEVP, 
    VALOR_PARC, VENC_PARC")] CAD_DEVP cAD_DEVP)

And then treat the data normally, as it did with the others.

    
15.08.2017 / 03:52