开发者

MVC3 Display text using Model

开发者 https://www.devze.com 2023-04-08 17:15 出处:网络
I am trying to display a text on the view from the database. <%@ Page Title=\"\" Language=\"C#\" MasterPageFile=\"~/Views/Shared/Admin.Master\" Inherits=\"System.Web.Mvc.ViewPage<IEnumerable<

I am trying to display a text on the view from the database.

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<HUI.Models.Events>>" %>

Tried to use the following but did not work

 开发者_如何学Python<%:Model.First().Name.ToString();%>

Thanks in advance.


How is the semicolon after ToString not giving you a compilation error?

If Name property is of type string then this should simply suffice:

<%:Model.First().Name %>

Can you send the error details if any, if this suggestion doesn't work?

Also - error details would help us too.


There are two issues here. First, you have the semi-colon at the end as others mentioned.

Secondly, you have:

IEnumerable<HUI.Models.Events>

Are you sure you don't want:

IEnumerable<HUI.Models.Event>
(Event - not Events)?

0

精彩评论

暂无评论...
验证码 换一张
取 消