0
我有一個AutomatOwners []類型的Web服務響應,其中AutomatOwners由兩個字段ID和名稱組成。我想創建一個選擇列表,然後將其顯示爲下拉列表,其中Name將作爲選項顯示,ID將作爲其選項值。 我的想法是這樣的:asp.net mvc selectlist - 字段到字典
ViewData["automat_owners"] = new SelectList((AutomatOwners[])web_service_response);
,並在視圖:
<%= Html.DropDownList("Owner", (SelectList)ViewData["automat_owners"]) %>
,但顯然這是不夠的。有任何想法嗎?