我想要一個列表,如果字段值距鏈接的實體數據模型太長,它將縮短字段值。東西在那裏我可以採取如下:向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