开发者

Parsing multiple checkbox values as a List

开发者 https://www.devze.com 2023-03-06 05:58 出处:网络
I\'m making a web application using MVC3 with C# I would like to get the checkboxes in my view defined as:

I'm making a web application using MVC3 with C#

I would like to get the checkboxes in my view defined as:

<input type="checkbox" name="group1[]" value="1" /> 
<input type="checkbox" name="group1[]" value="2" />
<input type="checkbox" name="group1[]" value="3" />

to be available as an List of values in the formCollection of a post method.

When I put a breakpoint it looks like the "group1" entry in the formCollection is indeed a list but I don't know how to get it using the 开发者_运维问答formCollection.Get method.


<input type="checkbox" name="group1[0]" value="1" /> 
<input type="checkbox" name="group1[1]" value="2" />
<input type="checkbox" name="group1[2]" value="3" />

Try using this

0

精彩评论

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