Multiline Label control in ASP.net

Hi,
I have a Datagrid that I use for data entry in an ASP.net application. In edit mode , the datagrid columns have textboxes that the users use to enter the data. Some of the columns might have data on multiple lines. When the user accepts (clicks on Save in the datagrid row) , the information in the datagrid is dsiplayed in the Label controls. But the data on multiple lines in the textboxes is displayed in one line in the datagrid.
How do I make it appear on multiuple lines in a label control also??

Thanks
LVL 1
TetraSAAsked:
Who is Participating?
 
raterusCommented:
It will look something like this, in ItemDataBound

If e.Item.ItemType <> ListItemType.Header and e.item.ItemType <> ListITemType.Footer Then
  Dim lblProDesc as Label = e.Item.FindControl("lblProDesc")
  lblProDesc.Text = cstr(DataBinder.Eval(e.item.DataItem, "sProdDesc")).Replace(vbCrLf, "<br/")
End If
0
 
raterusCommented:
myLabel.Text = sometext.Replace(vbCrLf, "<br/>")
0
 
TetraSAAuthor Commented:
Hi,
But how can I do this while rendering a datagrid?. Coz, the label is in a datagrid and the datagrid is connected to a dataset source.

Thanks
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
raterusCommented:
how does your column look in the datagrid?, you will need to add this code in ItemDataBound
0
 
TetraSAAuthor Commented:
Hi,
It has a template colum which has a label control "lblProDesc". The field name of the dataset is "sProdDesc".
What statement will I have in the ItemDataBound event??

Thanks
0
 
TetraSAAuthor Commented:
Thansk a lot. Worked perfectly.
0
 
David RobitailleAnalyst ProgrammerCommented:
you could also bind it directly in the datagrid :
replace '<%# Bind("sProdDesc") %>'
with
'<%# DataBinder.Eval(Container.DataItem, "sProdDesc").toString.Replace(vbCrLf, "<br/>") %>'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.