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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

raterusCommented:
myLabel.Text = sometext.Replace(vbCrLf, "<br/>")
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
raterusCommented:
how does your column look in the datagrid?, you will need to add this code in ItemDataBound
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TetraSAAuthor Commented:
Thansk a lot. Worked perfectly.
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/>") %>'
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.