Handling Html.DropDownList error 'IEnumerableSelectListItem' that has the key 'table

1

I tried to do a droplist and I searched for the solution in many forums but I can not solve my problem.

the list is filled with the database and even everything is fine, but in the view it shows me the error mentioned in the header and I do not know exactly why this error is generated. My model is as follows:

 public class TipoAfiliacion : SelectListItem

 {

    public int Id { get; set; }

    public string consecutivo_Codigo { get; set; }

    public string Descripcion { get; set; }
}

It should be noted that my list is called from the same original driver, so no other has been created to call the original view.

   public class AfiliacionTapaController : Controller
{
    // GET: AfiliacionTapa
    public ActionResult ControlCalidadFIR()
    {
        var Listadoin = new CalidadVerificacionFIR();
        var listadoOut = new List<AfiliacionCotizanteTapa>();
        listadoOut = Listadoin.traeErrFir();
        int posicion = 0;
        var numero = listadoOut[posicion];// objeto en la posicion 0
          byte[] imageByteData = System.IO.File.ReadAllBytes(numero.Url);
        string imageBase64Data = Convert.ToBase64String(imageByteData);
        string imageDataURL = string.Format("data:image/png;base64,{0}", imageBase64Data);
        ViewBag.ImageData = imageDataURL;

        return View(numero);

    }
    public ActionResult tablaAyudaTipoAfiliacion()
    {

        var listadoAyudaTipoAfili = new ConexionBDReplicaSOS();
        var tabla = new List<TipoAfiliacion>();
        tabla = listadoAyudaTipoAfili.tablaAyudaTiposAfiliacion("SP_TIPOSAFILIACION");

        var list = new SelectList(tabla, "consecutivo_Codigo", "Descripcion");
        ViewData["tabla"] = list;

        return View();
    }

the view:

  <tr>
        <th>@Html.DisplayNameFor(model => model.tipoAfiliacion)</th>

      <th>@Model.tipoAfiliacion</th>

      <th>@Html.DropDownList("tabla", ViewData["tabla"] as SelectList)   </th>     

    </tr>

At last I realized that the problem is generated because I can not fill my list from the ActionResult tableHelpTypeAffiliation, and I do not know if nobody is invoking that method when running the application.

So how should I pass data to my view if it comes from another actionResult ?

    
asked by usernovell 25.07.2016 в 16:17
source

0 answers