Formview Replace function: Add LineFeed

S

sck10

Hello,

When I open a FormView in View mode, the line breaks are missing, but they
show up when I enter edit mode. So I tried to use the following on a
Textbox with a replace function, but got the following error:

Public member 'Replace' on type 'DBNull' not found.

<asp:Label ID="lblArchReviewItem"
Text='<%# Eval("ArchitectReview").Replace(vbcrlf,"<br />").Trim() %>'
runat="server" />

Also, I would looking around and I read that you shouldn't really be using
VbCrlf anymore. Is this true?

Any help with this would be appreciated.
 
S

Steven Cheng[MSFT]

Hi Sck10,

Thank you for posting.

As for the replace function, it can be used with the vbcrlf when you are
using VB.NET as the programming language. I think the problem in your page
is caused by the Eval function, this expression will not directly return
the string, it will return an object instance, so if you want to use string
operation on the object, be sure to call the ToString function first. For
example:

<asp:Label ID="DescriptionLabel" runat="server" Text='<%#
Eval("Description").ToString().Replace(vbcrlf,"<br/>") %>'>

This works well on my test page.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top