Introduction
Today I had big trouble with text wrapping in an ASP.NET DataGrid
. No matter what I did in the CSS, the grid's <td>/<tr> came out like this:
Scratching my head
So I scratched my head for a while, Googled a bit, and tried HttpUtility.HtmlEncode
. No success. It does not convert a space to a non-breaking space. So I scratched again and then added this code in a module:
Option Strict On
Option Explicit On
Imports System.Runtime.CompilerServices
Module Extensions
< Extension() > _
Public Function SpaceToNbsp(ByVal s As String) As String
Dim space As String = " "
Return s.Replace(" ", space)
End Function
End Module
In the code above:
Dim space As String = " "
should be
Dim space As String = "" ""
Then I wrote this code:
row("Borgnummer") = i.OrgNummer.Text & " / ".SpaceToNbsp & i.PersNummer.Text
Voila! It came out just as I wanted: