Tuesday, June 14, 2011

Display data in label field and have line breaks that user entered in textbox

I received a request to modify a text to keep a line breaks previously entered in textbox. I tried several different methods to accomplish this task. The best solution is

<asp:Label ID="commentLabel" runat="server" Text='<%# Eval("comment").ToString().Replace(vbCRLF, "<br/>") %>' Wrap="true" />

It works very well. Thanks Forums.asp.net for quick and very elegant solution. My coworker have already whispered "Alla, Good Job!" It makes my day!

No comments:

Post a Comment