让我先问这个问题。
调用加载要在视图上显示的值列表的函数的正确位置在哪里?
我创建一个这样的控制器
public ActionResult Create()
{
SeaModel newSea = new SeaModel();
return View("Season/CreateSea", newSea);
}
//I not quite sure if this should go here or in another place
partial class seaDataContext
{
public List<string> getSeaSettings()
{
var seaSettings = from p in settings
where p.setting == "periods"
select p.value;
return seaSettings.ToList<string>();
}
}
模型就像
public class SeaModel
{
[Required(ErrorMessage="*")]
[Display(Name = "Period Name")]
public string periods { get; set; }
}
哪个创建一个像
@using (Html.BeginForm()) {
@Html.ValidationSummary(true, "Please correct the following errors.")
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
@Html.LabelFor(model => model.periods)
</div>
<div class="editor-field">
@Html.Select(model => model.periods, ****My doubt comes here****)
@Html.ValidationMessageFor(model => model.periods)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
那么,如何以及在哪里将 getSeaSettings() 的返回值传递给视图?
谢谢