how to wrap text in boundfield column in gridview

后端 未结 3 768
灰色年华
灰色年华 2021-01-01 01:45

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 no

相关标签:
3条回答
  • 2021-01-01 01:55

    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

    0 讨论(0)
  • 2021-01-01 01:58

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

    0 讨论(0)
  • 2021-01-01 02:05

    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();
    
    0 讨论(0)
提交回复
热议问题