Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将枚举值传递到@Html.ActionLink_C#_.net_Html_Asp.net Mvc 3 - Fatal编程技术网

C# 如何将枚举值传递到@Html.ActionLink

C# 如何将枚举值传递到@Html.ActionLink,c#,.net,html,asp.net-mvc-3,C#,.net,Html,Asp.net Mvc 3,我有一些方法 public ActionResult ExportToCSV(CellSeparators cellSeparator) { // } public enum CellSeparators { Semicolon, Comma } 如何在html中正确引用该方法 @Html.ActionLink("Exportar al CSV", "ExportToCSV", new { ?? }) 谢谢大家! @Html.ActionLink(“Ex

我有一些方法

public ActionResult ExportToCSV(CellSeparators cellSeparator)
{
  //
}          

public enum CellSeparators
{
   Semicolon,
   Comma
}
如何在html中正确引用该方法

@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { ?? })
谢谢大家!

@Html.ActionLink(“Exportar al-CSV”,“ExportToCSV”,新的{cellsepender=(int)cellsependers.分号)

不是很优雅,但在视图中很有用。cshtml:

@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { cellSeparator=CellSeparators.Semicolon })
进入控制器:

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

  /* ... */
}
也可以使用字典
public ActionResult ExportToCSV(CellSeparators? cellSeparator)
{
  if(cellSeparator.HasValue)
  {
    CellSeparator separator = cellSeparator.Value;
  }

  /* ... */
}