我想要一个列表,如果字段值距链接的实体数据模型太长,它将缩短字段值。东西在那里我可以采取如下:向asp.net mvc模型添加一个计算的字段
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcDR.Models.DONOR_LIST>>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Lists</h2>
<table>
<tr>
<th></th>
<th>LIST_NAME</th>
<th>SUMMARY</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td><%: Html.ActionLink("Details", "Society", new { id = item.DONOR_LIST_ID })%> |</td>
<td><%: item.LIST_NAME %></td>
<td><%: item.SUMMARY%></td>
</tr>
<% } %>
</table>
并更换
<td><%: item.SUMMARY%></td>
与
<td><%: item.SHORT_SUMMARY%></td>
在Ruby中这样做是非常简单的,但我不确定如何做到这一点在asp.net mvc的实体数据模型中工作。
你的意思是显示一个较短的版本(或切断与一些点文字......)如果概要的概要的即大于15 0个字符? – 2010-08-13 17:13:50
http://stackoverflow.com/questions/271398/what-are-your-favorite-extension-methods-for-c-codeplex-com-extensionoverflow/1512463#1512463 – Omar 2010-08-13 18:14:34