Help generating a table to capture information wn c # mvc

1

The problem that I present is the following.

1.- In a View I have to capture fields for two models, then what I do is the following.

in the index actionresult, in order to generate the model I occupy the following.

var user = db.MtoUsuarios.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();
        if (user == null)
        {
            RedirectToAction("Index", "Home");
        }

        ViewBag.MtoCompaniaId = new SelectList(ComboHelper.GetCompanias(0), "MtoCompaniaId", "Nombre");
        ViewBag.MtoTipoCompraId = new SelectList(ComboHelper.GetTipoCompra(0), "MtoTipoCompraId", "Descripcion");
        ViewBag.MtoTipoEventoId = new SelectList(ComboHelper.GetTipoEvento(0), "MtoTipoEventoId", "Descripcion");
        ViewBag.MtoTipoMercadoId = new SelectList(ComboHelper.GetTipoMercado(0), "MtoTipoMercadoId", "Descripcion");


        ViewBag.Tareas = ComboHelper.GetTareasAll();

        var Procedimiento = new MtoProcedimiento
        {
            MtoUsuarioId = user.MtoUsuarioId,
            MtoCompaniaId = user.MtoCompaniaId,
            MtoEstadoId = ComboHelper.GetStatus("Activo", db),              
        };

        return View(Procedimiento);

until there is no problem; the problem is when I recover the data from the ViewBag.Tareas in the view, which I do in the following way.

@{
List<WebDBT.Models.MtoTarea> tareas = ViewBag.Tareas;
}

now I generate a table to be able to capture the information of the tasks as follows.

<div class="table-title">                           
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th>Descripción de la Tarea</th>
                                    <th>Fecha Inicio</th>
                                    <th>Fecha Fin</th>                                        
                                </tr>
                            </thead>

                            @foreach (var item in tareas)
                            { 
                                <tr>
                                    <td>@Html.DisplayFor(modelItem => item.Descripcion)</td>
                                    <td class="col-md-2"><input type="text" class="datepicker" /><td>
                                    <td class="col-md-2">@Html.TextBox("FechaFin",null, new { @class = "datepicker"})</td>                                       
                                </tr>
                            }
                        </table>                            

                    </div>

Well the table generates me, but if you realize in the fields that I try to generate the 2 way html & @html; in both cases I put the class "datepicker" ; however for the last 2 records of both cases it does not show the datapicker that should show.

the script is as follows.

<script>
    //=======================================
    //DESCRIPCION:PARAMETRIZACION PAR CAMPOS DE TIPO FECHA
    //FECHA : Marzo 22, 2018
    //=======================================
    $(function () {
        $('.datepicker').datetimepicker(
            {
                format: 'DD-MM-YYYY',                   
            });

    });
</script>

could help me or confirm if, I'm doing well to generate the table and respect the class.

thanks.

    
asked by Horacio Xochitemol 26.06.2018 в 16:38
source

0 answers