开发者

ASP.net MVC 2 EditorFor Dictionary Bind

I try this, but 开发者_如何学Pythondon't work.

bemutatkozas@Modify = null all the time.

 public class Iroda
 {
        public Dictionary<int,string> bemutatkozas { get; set; }
 }

 public ActionResult Index()
 {
      var dct = new Dictionary<int, string>();
      dct.Add(1, "magyar");
      dct.Add(2, "angol");
      dct.Add(3, "olasz");

      return View(new Iroda { bemutatkozas = dct });
 }

 [HttpPost]
 public ActionResult Modify(Dictionary<int,string> bemutatkozas)
 {
      return View();
 }




<% using (Html.BeginForm("Modify","Iroda"))
       {%>
    <%= Html.ValidationSummary(true) %>
    <fieldset>
        <legend>Fields</legend>
        <%= Html.EditorFor(o=>o.bemutatkozas,"MultiLanguageEditor") %>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
    <% } %>

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Dictionary<int, string>>" %>
<% int i = 0; %>
<% foreach (var s in Model)
   { %>
<%= Html.Hidden(Html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix+"["+i+"].key", s.Key) %>
<%= Html.TextBox(Html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix+"["+i+"].value",s.Value) %>
<% i++; %>
<% }%>

Whats the solution? Thx!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜