最初に質問させてください。
ビューに表示する値のリストをロードする関数を呼び出す正しい場所はどこですか?
このようなコントローラーを作成します
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() の戻り値をビューに渡す方法と場所は?
ありがとう