在MVC3中包含模型 [英] include model in view in mvc3

查看:123
本文介绍了在MVC3中包含模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi;
我想将我的数据库实体包括在mvc3 aspx的视图页面中,以便我可以这样写
<%@ model下拉列表.Models.ProjectManagementSystemEntities%>
但这不是写的,所以我该怎么写?

hi;
i want include my database entities in view page of mvc3 aspx so i can write like this
<%@model dropdownlist.Models.ProjectManagementSystemEntities %>
but this is not write so how can i write?

推荐答案

你好,

如果要在视图页面中添加您的实体,请首先在控制器中提及它,例如:

Hello There,

If You Want to add your entity in view page then first mention it in controller like :

var varProjectManagement = from sec in objdata.ProjectManagementSystemEntities select sec;

ViewData["ProjectManagement"] = new SelectList(varProjectManagement .ToList(), ionId", "Text");



然后在类似:-
的视图中使用此viewdata



and then use this viewdata in view like :-

@Html.DropDownList("ProjectManagement", (IEnumerable<SelectListItem>)ViewData["ProjectManagement"],"--Select--")



希望对您有帮助

问候
安迪.



Hope this will help you

Regards
Andy.


这篇关于在MVC3中包含模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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