Asp.net mvc 如何将选定值DropDownList从View Razor发送到控制器MVC

Asp.net mvc 如何将选定值DropDownList从View Razor发送到控制器MVC,asp.net-mvc,asp.net-mvc-4,razor,Asp.net Mvc,Asp.net Mvc 4,Razor,我在HTTPGET控制器中有这个 SelectList ConvenioList = Utilidades.ObtenerConveniosList(); ViewData["ConveniosList"] = ConvenioList; return View(); 在Razor视图中,这些代码表示DropDownList中的列表,如下所示: @Html.DropDownList("ConveniosList", (IEnumerable<SelectListItem>)View

我在
HTTPGET
控制器中有这个

SelectList ConvenioList = Utilidades.ObtenerConveniosList();
ViewData["ConveniosList"] = ConvenioList;
return View();
在Razor视图中,这些代码表示
DropDownList
中的列表,如下所示:

@Html.DropDownList("ConveniosList", (IEnumerable<SelectListItem>)ViewData["ConveniosList"], new { @class = "form-control pull-right", @id = "ConvenioId", @style = "color:black;" })
@Html.DropDownList(“ConveniosList”,(IEnumerable)ViewData[“ConveniosList”],新{@class=“form control pull right”,@id=“ConvenioId”,@style=“color:black;”
然后列表在屏幕上显示如下:

带数据的下拉列表

我希望当选定的一个项目和summit search按钮在控制器帖子中获得选择值时,如下所示:

 [HttpPost]
  public ActionResult Transactions (string rangofecha, [<selected list value>] , string referencia)
  { //do soothing with the values received  }
[HttpPost]
公共操作结果事务(字符串rangofecha,[],字符串referencea)
{//使用收到的值进行安抚}

在您的视图中,您有:

@Html.DropDownList("ConveniosList", (IEnumerable<SelectListItem>)ViewData["ConveniosList"], new { @class = "form-control pull-right", @id = "ConvenioId", @style = "color:black;" })
您必须将
ConventionList
声明为字符串的原因是,当您从下拉列表中选择一个值时。。该值被发送到控制器。。并且该值的类型为string


让我知道这是否有帮助。

公共操作结果事务(字符串rangofecha、字符串ConventionList、字符串referencea)
应该这样做。选择的值只是一个变量。好极了,兄弟,这比我想象的要简单。非常感谢。OP没有显示生成选择列表的代码,但是选项值可能是
int
,在这种情况下,它应该是
int ConveniosList
(不是
string
public ActionResult Transactions (string rangofecha, /*[<selected list value>]*/string ConveniosList , string referencia)