日期:2014-05-17 浏览次数:20534 次
<asp:TemplateField HeaderText="备注?" ItemStyle-HorizontalAlign="Left"> <ItemTemplate> <%#Eval("Remark").ToString().Length > 20 ? Eval("Remark").ToString().Substring(0, 20) + "..." : Eval("Remark")%> </ItemTemplate> </asp:TemplateField>
------解决方案--------------------
public string DealAddress(string address) { string str = ""; if (address == "") { str = ""; return str; } if (address != "" && address.Length > 20) { str = address.Substring(0, 20) + "..."; } else { str = address; } return str; }
------解决方案--------------------
显示固定的几个字,后面用省略号... ...