break the text into multilines
Hi all
i am getting the data from table from select command by using data source and i am displaying the data in gridview
in that i am showing name and email etc
here my requirement is i am unable to break the email text into two lines if i am stricting the width to 10% as the email text is a single word
How can i break it
With Regards
TIS
[396 byte] By [
tis707] at [2007-11-20 9:19:49]

# 4 Re: break the text into multilines
Hi ra prabhat this is bhaskar.
If you are using either DataGrid or GridView place a lable in item template
and write the code in Item Data Bound Event.
Here is the Code.. This code is in asp.net just convert this to C#.net..
Protected Sub dgSpecialOffers_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgSpecialOffers.ItemDataBound
Try
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim lblDescription As New Label
Dim Description As String
lblDescription = e.Item.FindControl("lblDescription")
lblDescription.Text = DataBinder.Eval(e.Item.DataItem, "Description")
If lblDescription.Text.Length > 60 And lblDescription.Text.Length < 120 Then
Description = lblDescription.Text.Substring(0, 60)
Description += "<br>"
Description += lblDescription.Text.Substring(60)
lblDescription.Text = Description
ElseIf lblDescription.Text.Length > 120 And lblDescription.Text.Length < 180 Then
Description = lblDescription.Text.Substring(0, 60)
Description += "<br>"
Description += lblDescription.Text.Substring(60, 120)
Description += "<br>"
Description += lblDescription.Text.Substring(120)
lblDescription.Text = Description
ElseIf lblDescription.Text.Length > 180 And lblDescription.Text.Length < 240 Then
Description = lblDescription.Text.Substring(0, 60)
Description += "<br>"
Description += lblDescription.Text.Substring(60, 120)
Description += "<br>"
Description += lblDescription.Text.Substring(120, 180)
Description += "<br>"
Description += lblDescription.Text.Substring(180)
lblDescription.Text = Description
Else
lblDescription.Text = DataBinder.Eval(e.Item.DataItem, "Description")
End If
End If
Catch ex As Exception
End Try
End Sub
# 5 Re: break the text into multilines
Hi ra prabhat this is bhaskar.
If you are using either DataGrid or GridView place a lable in item template
and write the code in Item Data Bound Event.
Here is the Code.. Hi !
Welcome to dev-archive forum and thx for your help here. But Please read our posting rules first and use codetags as we all use for getting better readable code.
:wave: