Using textbox for in foreach loop or for loop of the Model

544 views Asked by At

I have a model in a view which is a list:

public PartialViewResult ParcialAlmacenProductoTerminado()
{
    var usuario = Fn.usuario_logeado.traerUsuario();
    ViewBag.usuario = usuario;
    List<op> ops = db.op.Where(x => x.temp != true && x.revisado == true && x.calidad == true && x.calidadRevision == true).ToList();

    return PartialView(ops);
}

And in my view I have this in the model area:

@model List<Produccion.Models.op>

I want to go through it with a foreach or a for (i already tried both) and create and html.textboxfor.

This is the attempt with the for:

@for (int i = 0; i < Model.Count; i++)
{
    @Html.TextBoxFor(x => x.OrdenDeCompra[i], new { @class = "form-control obligatorio " })
}

and the one with the foreach:

@foreach (var p in Model)
{
    @Html.TextBoxFor(x => x.OrdenDeCompras, new { @class = "form-control obligatorio "})
}

none of them work

0

There are 0 answers