htmlasp.netdatagridview

More than one space between two words in gridview asp.net


I am using a gridview in my asp.net web site. I load a text file into the gridview, the text file has words which are separated by more than one space like this:

  program          asp.net

My problem is that when I display this on my gridview, the space between "program" and "asp.net" is limited to only one space!

Can anyone help me?


Solution

  • Replace spaces with &nbsp, or add css class:

    .wspace {
        white-space:pre; // or pre-wrap if you want wrapping to still work.
    }
    

    and then wrap content of that GridView cell into <div class="wspace "> ... </div>
    Also, you can wrap cell content into <pre> which does the similar trick, but be aware of "pre" html semantics/meaning.