Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to wrap text in boundfield column in gridview

Tags:

c#

asp.net

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

like image 346
Abhimanyu Avatar asked Oct 27 '10 04:10

Abhimanyu


3 Answers

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" />

like image 97
Chris Avatar answered Oct 20 '22 00:10

Chris


Supported in all but Opera (Even works in IE6!):

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

More info here

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

Extra resource

like image 29
Daniel Szabo Avatar answered Oct 19 '22 23:10

Daniel Szabo


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();
like image 24
Edy Cu Avatar answered Oct 19 '22 23:10

Edy Cu