2012-09-03 17 views

Respuesta

2

@ Html.ActionLink ("Exportar al CSV", "ExportToCsv", nueva {cellSeparator = (int) CellSeparators.Semicolon})

Y

public ActionResult ExportToCSV(int cellSeparator) 
{ 
    CellSeparator separator = (CellSeparator)cellSeparator; 
} 

no es elegante, pero es muy útil

+0

¡Gracias! Tu enfoque está funcionando. –

+1

También RouteValueDictionary http://stackoverflow.com/questions/3976371/pass-collection-of-enums-to-asp-net-mvc-actionmethod –

2

En su View.cshtml:

@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { cellSeparator=CellSeparators.Semicolon }) 

En su controlador:

public ActionResult ExportToCSV(CellSeparators? cellSeparator) 
{ 
    if(cellSeparator.HasValue) 
    { 
    CellSeparator separator = cellSeparator.Value; 
    } 

    /* ... */ 
} 
Cuestiones relacionadas