下拉mvc3..wont填充字段

时间:2012-04-23 16:26:46

标签: c# asp.net-mvc-3

我有这个控制器:

    public class NewPostController : Controller
{
    List<SelectListItem> languages= new List<SelectListItem>();
    public ActionResult Index()
    {
        ViewData["languages"] = new SelectList(languages, "Text", "Value", 1); 
        return View();
    }


    private void GetCountryList()
    {
        CultureInfo[] cultureList = CultureInfo.GetCultures(CultureTypes.AllCultures);

        foreach (CultureInfo culture in cultureList)
        {


            languages.Add(new SelectListItem
            {
                Text = culture.DisplayName,
                Value = culture.DisplayName,
              });


        }

    }

}

项目清单应按其语言建立并传递给视图。

            @Html.DropDownList("languages",null,
    "** Please Select **",
    new { @class = "my-select-css-class" })

什么都没有填充..为什么?

1 个答案:

答案 0 :(得分:1)

GetCountryList()

你永远不会打电话。