有人可以为我提供一个很好的控制器示例来处理模型的选中复选框吗?
例如。我将如何在控制器中仅获取选中的项目以及它们相应的下拉框值?
风景
<form>
<table>
<tr>
<td>
<input type="checkbox" name="something" value="12345" checked="true" />
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="something" value="54321" checked="false" />
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="something" value="11111" checked="false" />
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
</tr>
</table>
<input type="submit" />
</form>
该模型
public class FormCollection
{
// how would this look?
}
控制器
public ActionResult Sort(FormCollection model)
{
FormCollection _model = new FormCollection();
// iterate through model to get only values that are checked
// add them to _model
// how would this look?
}