Dear All,
How can I Pass the Value from the View to Controller i.e.
I have a static Dropdown which I have created as follows.
1) Controller Code
var list = new SelectList(new[]
{
new { ID = "1", Name = "name1" },
new { ID = "2", Name = "name2" },
new { ID = "3", Name = "name3" },
},
"ID", "Name", 1);
ViewData["list"] = list;
2) In My View I am binding the Dropdown as follows:
@Html.DropDownList("list", ViewData["list"] as SelectList)
how can I get the selected value of the dropdown from view and pass it to a controller?
I tried the following but it did not work.
string sTest = Request.Form["list"].ToString();
What I have tried:
string sTest = Request.Form["list"].ToString();