简单的下拉列表

时间:2011-09-27 09:27:16

标签: asp.net-mvc-3 razor

我没有找到简单的下拉列表。

我是mvc3的新手

此部分创建并填充:ListMonitoringLicenseModelList = new List();

我在另一部分中填充此objectsList并使用它来填充MonitoringLicenseModelList

objectsList = new List(... fill objectsList ...);

    List<MonitoringLicenseModel>MonitoringLicenseModelList = new List<MonitoringLicenseModel>();
        foreach (object o in objectsList)
        {
            string[] tmpString = o.ToString().Split('@');

            int i = 0;

            monitoringLicenseModel = new MonitoringLicenseModel();
            monitoringLicenseModel.MonitoringID =Convert.ToInt32(tmpString[i++]);
            monitoringLicenseModel.LicenseUI = tmpString[i++];
           MonitoringLicenseModelList.Add(monitoringLicenseModel);
        }

public ActionResult SchedulesIndex()         {

        return View(MonitoringLicenseModelList);
     }

如何编写下拉列表以显示此内容

                 name                value

            MonitoringID   =     LicenseUI 

1 个答案:

答案 0 :(得分:0)

@model List<MonitoringLicenseModel>
...
@Html.DropDownList(
    "SelectedMotoringID", 
    new SelectList(Model, "MonitoringID", "LicenseUI")
)