2010-04-22 67 views
0

我需要在操作方法中獲取表單上選定複選框的值 您將如何執行此操作? (或可能讓他們所有,看看誰被選中)如何在發佈操作(選中複選框)中獲取ids int []的集合

public ActionResult (int[] ids) 

...

<input type="checkbox" value = "1" /> 
<input type="checkbox" value = "2" /> 
<input type="checkbox" value = "3" /> 
<input type="checkbox" value = "4" /> 

<%=Html.Submit(); %> 

回答

4

你可以嘗試給複選框的名稱(IDS):

<input type="checkbox" name="ids" value="1" /> 
<input type="checkbox" name="ids" value="2" /> 
<input type="checkbox" name="ids" value="3" /> 
<input type="checkbox" name="ids" value="4" /> 

應工作附:

public ActionResult Index(int[] ids) { ... }