Hi Cathie,
It looks like you'll have to add your own line breaks. Here's some sample
code that uses the ItemDataBound event to check for the length of the text
in the first cell. If it is greater than 20 characters, it loops through the
string and inserts a break (<br>) every 20 characters.
Private Sub DataGrid1_ItemDataBound _
(ByVal sender As Object, ByVal e As _
System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBound
Dim strAllText As String
Dim strNewText As String = ""
Dim intPos As Integer = 1
If Len(e.Item.Cells(0).Text) > 20 Then
strAllText = e.Item.Cells(0).Text
While intPos < Len(e.Item.Cells(0).Text)
strNewText = strNewText & _
Mid(strAllText, intPos, 20) & "<br>"
intPos = intPos + 20
End While
e.Item.Cells(0).Text = strNewText
End If
End Sub
Does this help?
Ken
Microsoft MVP [ASP.NET]
Toronto
Cathie Hagen said:
Hi All,
I have a long string with no whitespace or break character and it is
ruining
the formatting of my datagrid. How can I get the text to wrap whether or
not their are break characters in the string?
Thanks in advance
Cathie