English 中文(简体)
ASP MVC3 - 域名Model & Razor——从数据库中显示信息
原标题:ASP MVC3 - DomainModel & Razor - displaying info from the database

目前,我有“DomainModel”,通过EDMX处理所有数据。

当我使用一个ASPX网页时,我能够使用以下代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<DomainModel.aspnet_Membership>>" %>
<% foreach (DomainModel.aspnet_Membership member in Model)
   {
List<DomainModel.aspnet_Roles> roles = member.aspnet_Users.aspnet_Roles.ToList();
}

该名单通过Model域网把所有会员从Kal-DB返回。

不过,现在我必须使用欧文超声拉平页。 (Using “@”代码区)

我试图执行类似的法典,但总是落在以下几个方面:

@model IEnumerable<DomainModel.aspnet_Membership>
@foreach (DomainModel.aspnet_Membership m in Model)
{
<b>@m.aspnet_Users.UserName</b>
}

编辑:错误:NullReferenceException未经处理。 Obj 参考文献

主计长(我原想在现在发生同样错误,但在控制人员中加入这一守则)

<代码>私人产品Name_SATEntities_context;>[HttpParamAction] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Scenario(){回归观点(_context.SAT_Scenarios.ToList()); - 数据和元数据交换所生成的内容的文字链接

最佳回答

如果不是:

@model IEnumerable<DomainModel.aspnet_Membership>
@{foreach (DomainModel.aspnet_Membership m in Model)
{
    <b>@(m.aspnet_Users.UserName)</b>
}}

? 我在<条码>上添加了条码(<条码>{>>和<条码>>>>>>>。 否则,汇编者会认为,您的网页上需要<代码>foreach,这是一个汇编时的错误。

我还在<代码>m.aspnet_Users.UserName上添加括号(()以方便生活:它应当不工作,但与此同时,我们默示控制了汇编者将考虑服务器-侧代码(如>/code>,无限期不中断)。

问题回答

暂无回答




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...