MVC Html.CheckBox and form submit issue

后端 未结 4 1557
醉酒成梦
醉酒成梦 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:46

       <% using(Html.BeginForm("Retrieve", "Home")) %>//Retrieve is the name of the action while Home is the name of the controller
           <% { %>
        <%foreach (var app in newApps)              { %>  
       
           <%=Html.CheckBox(""+app.ApplicationId )%>      
    
         
    <%} %>
     
    <% } %>
    

    and in your controller

     List=newApps; //Database bind
     for(int i=0; i

    the reason you check for false because the Html Checkbox helper does some kind of freaky thing for value true

    True returns as:

    it makes the string read "true, false"
    

    so you may have thought it was two values but its just one and means true

    False returns as:

    it makes the string read "false"
    

提交回复
热议问题