|
public ActionResult Index()
{
Dataset oDataSetCountry = GetDataSet();
List list = new List { };
foreach(DataRow oDataRow in oDataSetCountry.Tables[0].Rows)
{
SelectListItem oSelectListItem = new SelectListItem { Value = (String)oDataRow["CountryCode"],Text = (String)oDataRow["CountryName"]};
list.Add(oSelectListItem);
}
ViewData["DDLCountry"] = list;
return View(oCountry);
}
// Get value from view.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(FormCollection frmCollection)
{
string dropDownSelectedValue = frmCollection.Get("DDLCountry");
ViewData["Test"] = dropDownSelectedValue;
return Redirect("Index");
}
in the aspx file .
<%= Html.DropDownList("DDLCountry", "LoLo")%>;
|