在GridView中,设置字符超出单元格部分的内容用“...”表示,代码如下:
<asp:TemplateField HeaderText="用途" SortExpression="USE_FOR">
<ItemTemplate>
<div style="width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none" title='<%# Eval("USE_FOR")%>'>
<asp:Label ID="lblUSE_FOR" runat="server" Text='<%# Bind("USE_FOR")%>'></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="用途" SortExpression="USE_FOR">
<ItemTemplate>
<div style="width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none" title='<%# Eval("USE_FOR")%>'>
<asp:Label ID="lblUSE_FOR" runat="server" Text='<%# Bind("USE_FOR")%>'></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
本文介绍在GridView中设置字符超出部分显示为省略号的实现方式,通过使用ASP.NET模板字段和自定义样式来解决字符溢出问题。
1万+

被折叠的 条评论
为什么被折叠?



