jQuery and ASP.NET

May 30, 2009

How to Prevent Word Wrap in an ASP.NET GridView




 

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!



'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

2 Responses to "How to Prevent Word Wrap in an ASP.NET GridView"
  1. Venkat said...
    June 11, 2009 5:39 AM

    Whether it will wrap the text or not ... I have not seen any difference , Let you give the sample code.. with the screenshot explanation.

  2. Anonymous said...
    August 2, 2010 3:45 AM

    Thanks it worked :)

 

Copyright © 2009-2011 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions