0
我有這個在我看來,這工作得很好,堅持選擇的國家:堅持值DropDownList的編輯模板
<%: Html.DropDownListFor(model => model.CountryId, Model.CountryList ,"Select Country") %>
然而,當我爲這個創建的編輯模板,選擇的國家是不持久
所以,我改變我目前看來這樣的:
<%: Html.EditorFor(model => model.CountryId,new { countries = Model.CountryList}) %>
然後,我創建我的編輯模板,像這樣:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Int64?>" %>
<%= Html.DropDownList(
String.Empty /* */,
(SelectList)ViewData["countries"],
Model
)
%>
實際上上面的代碼工作我只是忘記刪除第一行的舊代碼。這是另一個好主意 – 2010-12-19 17:22:31