MVC Html.CheckBox and form submit issue

后端 未结 4 1567
醉酒成梦
醉酒成梦 2020-12-17 16:11

Crazy issue with submitting of values in Html.Checkbox in ASP.NET MVC RC

Some of the values are just not come to Request.Params

At my form I have this line i

4条回答
  •  长情又很酷
    2020-12-17 16:39

    Without the need to ask database about the ids after form submitting/before saving (Stateless mode) I've produced such code:

        foreach (string key in Request.Form)
        {
            var checkbox = String.Empty;
            if (key.StartsWith("cb"))
            {
              checkbox = Request.Form["" + key];
    
              if (checkbox != "false")
              {
                  int id = Convert.ToInt32(key.Remove(0, 2));
              }
            }
        }
    

    Thanks you guys to help me work around this issue!

提交回复
热议问题