如何在视图中加载多个控件
我仍然不知道如何开始在 MVC 3 上准备这样的表单。
我是初学者,到目前为止我所学到的只是将数据从控制器绑定到强类型视图。但据我所知,我们只能从返回语句
public ActionResult(int id) 返回一个变量 { // 做一些逻辑 返回视图(角色); 现在上面
的代码将角色列表返回到视图。但是我将如何传递其他详细信息,例如许可证状态、组织..等*
另一个复杂的示例:
假设我的表单需要显示国家/地区[下拉]、州[下拉]、部门[组合框列表]、组织[等详细信息单选按钮列表],所有员工列表[表/网格]
如何使用单个 RETURN 显示所有控件值?
注意:* 我假设所有详细信息(例如角色、许可证状态、组织等)都是从数据库中获取的。
我希望我的解释很清楚,如果我需要进一步解释,请告诉我。
另外,我对这个愚蠢的问题感到抱歉,这是因为我正处于 MVC 的第一个学习阶段
I am still clueless how to start preparing a form like this on MVC 3.
I am a beginner and all I have learned till now is to bind data from controller to the strongly typed view. But as I know that we can return only one varibale from the return statment
public ActionResult(int id)
{
// Do some logic
return View(role);
}
Now the above code return the role list to the view. But how would I pass other details also like Licence state, organization.. etc *
Another complex example:
Let say my form need to display details like Country [drop down], State [Drop down], Department [ComboBox list], Organization [radio button list], List of all employee [table/Grid]
How would I display all the controls value with single RETURN?
Note: * I assume that all the detials like role, Licence state, Organization etc I am fetching from database.
I hope I am clear with my explanation, please let me know if I need to explain it bit further.
Also, I am sorry for this stupid question, this is because I am in my very first learning stage of MVC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将编写一个视图模型:
并在控制器操作中将此视图模型返回到视图:
并在视图中:
当然,每个部分都会有强类型编辑器模板:
这将代表每个部分的部分内容
You would write a view model:
and in your controller action you will return this view model to the view:
and in the view:
and of course you will have strongly typed editor templates for each section:
which will represent the partial contents of each section