values from the checkbox list send null

1

I have a checkbox list that feeds from a query to a database and so far well. But when sending the values of the checkbox, I send them to the controller and I would like to know how I can solve this or how to do it. It should be noted that the checkboxes that I send show whether it is marked or not. This is the model of the list:

  public class listaParametros
  {
     public int Preimpreso { get; set; }
     public List<ParametrosRevisionesVisuales> RevionVisual { get; private set; }
     public List<ParametrosAnexosAfiliacion> RevisionAnexos { get; private set; }

     public listaParametros(List<ParametrosRevisionesVisuales> ParametrosRevisionesVisuales, 
                            List<ParametrosAnexosAfiliacion> ParametrosAnexos)
     {
         this.RevionVisual = ParametrosRevisionesVisuales;
         this.RevisionAnexos = ParametrosAnexos;
     }

      public listaParametros() {}
 }

my controller:

 public ActionResult Index()
 {
    PreimpresoDao preimd = new PreimpresoDao();
    List<ParametrosAnexosAfiliacion> AnexosPorAfiliacion = new List<ParametrosAnexosAfiliacion>();
    AnexosPorAfiliacion = preimd.consultaParametrosAnexosAfiliacion();

    List<ParametrosRevisionesVisuales> ParametrosRevisionesVisuales = new List<ParametrosRevisionesVisuales>();
    ParametrosRevisionesVisuales = reimd.consultaParametrosRevisionVisual();

    listaParametros listas = new listaParametros(ParametrosRevisionesVisuales, AnexosPorAfiliacion);

    return View(listas);
 }


    [HttpPost]
    public ActionResult Create(listaParametros lis)
    {

        try
        {

            return RedirectToAction("Index");
        }
        catch
        {
            return View();
        }
    }

the view:

@using (Html.BeginForm("create", "listaParametros", new { @id = "Form1" }, FormMethod.Post))
{
    <fieldset class="fieldset1-revision-visual">
        <legend>Revision de Anexos:</legend>
        <table class="tabla-registros-revision1">
            @using (Html.BeginForm())
            {
                for (var i = 0; i < Model.RevionVisual.Count; i++)
                {
                    <tr>

                        <td>
                            @Html.CheckBoxFor(model => model.RevionVisual[i].isChecked)
                        </td>
                        <td style="font-family:courier;">
                            @Html.DisplayFor(model => model.RevionVisual[i].vchDescParametro)
                        </td>
                        @Html.HiddenFor(model => model.RevionVisual[i].siCodParametro)
                    </tr>
                }
            }
        </table>
    </fieldset>

    <fieldset class="fieldset2-revision-anexos">
        <legend>Revisiones Visuales:</legend>
        <table class="tabla-registros-revision2">
            @using (Html.BeginForm())
            {
                for (var i = 0; i < Model.RevisionAnexos.Count; i++)
                {
                    <tr>
                        <td>
                            @Html.HiddenFor(model => model.RevisionAnexos[i].siCodParametro)
                        </td>
                        <td>
                            @Html.CheckBoxFor(model => model.RevisionAnexos[i].isChecked, new { style = "height:20px" })
                        </td>
                        <td style="font-family:courier; font-size:15px">
                            @Html.DisplayFor(model => model.RevisionAnexos[i].vchDescParametro, new { @style = "font-family:verdana;" })
                        </td>

                    </tr>
                }
            }
        </table>

    </fieldset>

    <fieldset class="fieldset3-tabla-trabajo">
        <legend>Registrar preimpreso</legend>
        @Html.TextBoxFor(m => m.Preimpreso)
        <div>
           <button  type="submit" value="2" name="Grabar" class="w3-btn" >
               Grabar
           </button>
            <button type="submit" value="3" name="Eliminar"  class="w3-btn">
                Eliminar
            </button>
            <button  type="submit" value="4" name="Consultar" class="w3-btn">
                Consultar
            </button>
        </div>

    </fieldset>


}
    
asked by usernovell 13.09.2016 в 20:45
source

1 answer

1

I have already solved it, what happened was that first I had the "set as private" in the model and in the view I had several beginforms and I should only have one to send the data from the lists.

thanks.

    
answered by 13.09.2016 / 21:47
source