Recently I came across an interesting answer by Jason, where he suggests how to stop word wrap in an ASP.NET GridView. I thought of sharing this trick with the viewers facing similar issues:
The trick is to use
<td style="WORD-BREAK:BREAK-ALL;">
Check this sample:
<style type="text/css">
.DisplayDesc { width:500px;word-break : break-all }
.DisplayDiv { width:500px; OVERFLOW:hidden;
TEXT-OVERFLOW:ellipsis}
</style>
<asp:TemplateField>
<ItemStyle Font-Names="Tahoma" Font-Size="X-Small"
HorizontalAlign="Left"
Wrap="True" />
<ItemTemplate>
<div class="DisplayDiv">
<asp:Label CssClass="DisplayDesc" ID="Label1"
runat="server"
Text='<%# Bind("SomeLongText") %>'></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
I am sure there are many developers who had this problem in the past without a decent solution. Let me know if it worked for you!
Tweet
3 comments:
Whether it will wrap the text or not ... I have not seen any difference , Let you give the sample code.. with the screenshot explanation.
Thanks it worked :)
Great post. It worked!
Post a Comment