DataGrid 列换行和宽度问题
我有一个 asp.net 数据网格,一列显示地址。有时地址的长度比可以显示的长度长,所以我想截断显示。
我尝试过设置,但这只会使地址列更宽以容纳更长的文本(它也会影响前一列“名称”的宽度)。
有没有办法告诉列不要环绕或延伸超过设置的列宽度(在 CSS 中设置),或者我需要在将字符串绑定到数据网格之前限制字符串的长度?
谢谢, 凯文
I have an asp.net datagrid, one column displays the address. Sometimes the length of the address is longer than can be displayed, so I want to just truncate the display.
I have tried setting , but this just makes the address column wider to accommodate the longer text (it also effect the width of the preceding column, Name).
Is there a way to tell the column not to wrap or extend past the set column width (set in the CSS) or will I need to limit the length of the string before binding it to the datagrid?
Thanks,
Kevin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 TemplateColumn,并在 ItemTemplate 中执行类似以下操作:
Use a TemplateColumn, and do something like the following in the ItemTemplate:
您正在寻找 CSS 属性溢出。
您应该将其应用到您的单元格,因此您需要将
ItemStyle
上的CssClass
设置为定义了溢出的样式。我宁愿尽可能不使用溢出,并尝试截断并在末尾添加
...
以指示文本丢失,否则它可能会在空格后被切断,并且没有人会知道任何文本文本丢失。Your looking for the CSS property overflow.
You should apply that to your cell so you will need to set the
CssClass
on theItemStyle
to a style with overflow defined.I prefer to not use the overflow when possible and try to truncate and add a
...
to the end to indicate text is missing or else it could cut off after a space and no one would know that any text was missing.