把多餘文字字串變成...的好方法

文章真的要多看多聽
以前都是用程式判斷多餘的文字擷取多少字元後再組"..."回去
現在用CSS就可以做得到,又快又方便
<head>
<style>
.ellipsis_row { OVERFLOW: hidden; WIDTH: 50px; WHITE-SPACE: nowrap; TEXT-OVERFLOW: ellipsis }
</style>
</head>
然後在加入
<ItemTemplate>
然後在需要變化的文字上面,加入此類別即可
<DIV class="ellipsis_row"><%#DataBinder.Eval(Container.DataItem,"LastName")%></DIV>
</ItemTemplate>

請參考 ASP.NET DataGrid GridView DataList 限制資料長度超過時把文字變成 ... http://forums.microsoft.com/MSDN-CHT/ShowPost.aspx?PostID=1942097&SiteID=14

留言

熱門文章