Problem with free form text

G

Gary Wardell

Hi,

I have a free form text file, call Notes.

I want to be able to both display and edit and input this field in a
DetailsView control. This would seem to be a natural for a multiline text
box, but there doesn't seem to be one of these as a bound field in
DesignView.

The examples I've found all show using a Label in a Panel In an ItemTemplate
to display the field and a Multiline Textbox in the EditItemTemplate.

That all seems to work; so far so good and the page looks good.

Now comes the rub.

I want to be able to format the text with carrage returns.

The Label control wants these to be rendered as <br />; but the textBox
wants these rendered as CRLF.

I find there is a OnPreRender even that looks like I could replace the crlfs
with the proper new line sequence for the respective control.

Problem is, how do I refernce the Label and Textbox fields burried in the
templates in the DesignView from the PreRender event?

In desperation I tried using the textbox in the ItemTamplate and that works,
but the page looks a little funny having labels for all for the other fields
and a textbox for this one.

Gary
 
S

Stan

Hi,

I have a free form text file, call Notes.

I want to be able to both display and edit and input this field in a
DetailsView control.  This would seem to be a natural for a multiline text
box, but there doesn't seem to be one of these as a bound field in
DesignView.

The examples I've found all show using a Label in a Panel In an ItemTemplate
to display the field and a Multiline Textbox in the EditItemTemplate.

That all seems to work; so far so good and the page looks good.

Now comes the rub.

I want to be able to format the text with carrage returns.

The Label control wants these to be rendered as <br />; but the textBox
wants these rendered as CRLF.

I find there is a OnPreRender even that looks like I could replace the crlfs
with the proper new line sequence for the respective control.

Problem is, how do I refernce the Label and Textbox fields burried in the
templates in the DesignView from the PreRender event?

In desperation I tried using the textbox in the ItemTamplate and that works,
but the page looks a little funny having labels for all for the other fields
and a textbox for this one.

Gary

The label control is read-only so you can do what you like with the
text read from the database during the binding process. Have you tried
anything like this?

I'm not sure how to do this in VB but I have tried this in C# and it
seems to work:

<asp:label ID="labNotes" runat="server"
Text='<%# Eval("Notes").ToString().Replace("\n","<br />") %>'></
asp:label>

where the label is in the ItemTemplate and the column named "Notes"
contains line delimited text.

HTH
 

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,015
Latest member
AmbrosePal

Latest Threads

Top