How to wrap text in boundfield column in gridview

I have a column of a related field and in this column, if I entered a string (without spaces) of length 15, there is no problem. But if the line is greater than 15, the text is not wrapped. I gave the command column.ItemStyle.Wrap = true; But that does not work. I set the column width.

How to wrap text in a border field if a string contains more than 15 characters. Thanks

+6
source share
3 answers

Sorry for my previous solution.

You can use <br/> to split it for every 15 characters.

Example if the result of the line is 1234567890123456 . Failed 123456789012345<br/>6

Here is the code snippet:

 string myString = "mondayfridaysaturday"; string result = string.Empty; for (int i=0; i<myString.Length; i++) result += (i%14==0&&i!=0) ? (myString[i].ToString()+"<br/>") : myString[i].ToString(); 
+2
source share

I had a similar problem, I lost my mind. Turns out I had a RowStyle-Wrap set false , which in turn overrided itemstyle-wrap in a column of the associated field. Change your .aspx to <RowStyle Wrap="True" />

+6
source share

It is supported in all but Opera (even works in IE6!):

 .CSSClass{ word-wrap: break-word;} 

More info here

Edit - Woops, just found another resource that Opera also handles!

Additional resources

+3
source share

All Articles