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)?
精彩评论