的形式進入到一個列表或集合如何記錄值我正在開發使用C#和SQL Server 2005在ASP MVC
我用的也是實體框架和準則第一種方法的ASP淨MVC 3應用程序。
我有這樣的形式:
我想保存在列表中(或集合)entred值當我在按鈕「Enregistrer」點擊。
這是查看的代碼:
<fieldset class="parametrage">
<legend>Gestion de Gamme</legend>
<div><%:Html.Label("Poste :")%><%: Html.DropDownList("SelectedPoste", Model.PostesItems)%><input type="checkbox" name="option1" value="Poste Initial" id= "chkMain" onclick="test();"/>Poste Initial<input type="checkbox" name="option2" value="Poste Final" id= "chkFirst" onclick="test2();"/>Poste Final</div>
<div><%:Html.Label("Nombre de Passage :")%><%: Html.EditorFor(x=>x.YourGammeModel.Nbr_Passage)%></div>
<div><%:Html.Label("Position :")%><%: Html.EditorFor(x=>x.YourGammeModel.Position)%></div>
<div><%:Html.Label("Poste Précédent :")%><%: Html.DropDownList("PostePrecedentSelected", Model.PostesItems)%></div>
<div><%:Html.Label("Poste Suivant :")%><%: Html.DropDownList("PosteSuivantSelected", Model.PostesItems)%></div>
<div><input type="submit" value="Enregistrer" id="btnSave" /></div>
</fieldset>
視圖模型:
private static Dictionary<string, Gamme> userGammes;
public static Dictionary<string, Gamme> UserGammes
{
get
{
if (userGammes == null)
{
userGammes = new Dictionary<string, Gamme>();
}
return userGammes;
}
}
和控制器:
public ActionResult Save(Gamme gamme)
{
UserGammes.Add("currentUserID", gamme);
}
好吧。你有什麼嘗試?你卡在哪裏? –
@OndrejTucny是的,我試過,,,請檢查我的更新,但在控制器中的聲明不接受VS – anouar
我會建議在進入您自己的項目之前完成教程。 http://www.asp.net/mvc –