发布多个复选框 [英] Post multiple checkboxes

查看:105
本文介绍了发布多个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

首先,我不是经验丰富的MVC开发人员. :)

我想做的是通过循环遍历表中的每个对象在视图中显示我的模型(我可以这样做:)).在每行的右侧(即新列),我想要一个复选框,以使用户可以确认行中的数据正确.用户应该能够单击将每个已检查"行发送回服务器的按钮,在该服务器上将rowId发送到另一个称为已检查"的数据库表.

我的问题是,如何将其传递回服务器?应该传递一个formcollection,然后以某种方式遍历每一行并获取rowId?我应该使用视图模型并将模型传递回服务器吗?我猜这是最好的选择...但是这样的视图模型会是什么样子?我只使用过视图模型来创建新用户,而事实并非如此.

更正:我想我想知道的是如何将默认视图模板"Edit"与IEnumerable一起使用?

谢谢
Erik

Hey,

Let me first say, I''m not an experienced MVC developer. :)

What I want to do is to show my model in a view by looping out each object in a table(this I can do :) ). On the right side of each row, i.e an new column, I want a checkbox to make it possible for the user to confirm that the data in the row is correct. The user should the be able to click on a button that sends each "checked" row back to the server where the rowId is sent to another database table called "Checked".

My question is, how should I pass this back to the server? Should pass a formcollection and then iterate through each row in some way and get the rowId? Should I use a viewmodel and pass the model back to the server? I guess that''s the best option...but how would a viewmodel like that look like? I''ve only used viewmodels for like creating a new user, and this is not like that.

Correction: I guess what I want to know is how to use the default view template "Edit" with IEnumerable?

Thanks
Erik

推荐答案

我在Steven Sandersons博客上找到了答案.

http://blog.stevensanderson.com /2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/ [
I found the answer at Steven Sandersons blog.

http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/[^]


这篇关于发布多个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆