i am having a boundfield column and in that column if i entered a string(without spaces) of length 15, there is no problem. But if the string is more than 15, the text is not wrapped. I gave the command column.ItemStyle.Wrap=true; But its not working. I have fixed the width of the column.
How to wrap the text in the boundfield if a string more 15 characters.
Thanks
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I had a similar problem, drove me insane. Turns out I had RowStyle-Wrap set false, which in turn was overriding the itemstyle-wrap in the boundfield column. Change your .aspx to <RowStyle Wrap="True" />
Method 2
Supported in all but Opera (Even works in IE6!):
.wraptext { word-wrap: break-word;}
Edit —
Woops, just found another resource that handles Opera, too!
Method 3
Sorry, for my previous solution.
You could use <br/> to break for each 15 characters.
Example if you string result is 1234567890123456. It gone be 123456789012345<br/>6
Here some snippets code:
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();
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0