ASP.NET 2.0: Label Problem using formview

S

sck10

Hello,

I am pulling data from a SQL Server table. One field that is (varchar 4000)
is used to show notes. I am using a FormView for showing and editing the
data. When the form is in Item view, the text runs together. All the line
breaks are missing. When I enter into Edit mode, the text is formatted as
it was entered (line breaks).

How can I fix this so that when in "Item" mode, the line breaks show?
 
S

Steven Cheng[MSFT]

Hi Sck10,

Welcome to ASPNET newsgroup.
As for the displaying large text field in asp.net 2.0 FormView control
problem, I think it's because the FormView control by default only genearte
some text and Label control for displaying the data(not container element),
so when the data fields output a large text, it does not break the text
...... For such cases, I think we need to manually put some html element
around the large text or the template so as to force the text to bread into
lines.... e.g, we can use a html table with fixed width and word-break css
style as below:

=====================
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
DataKeyNames="id"
DataSourceID="SqlDataSource1">

<ItemTemplate >
<table width="200" style="table-layout: fixed;
word-break:break-all" >
<tr>
<td style="width: 128px">
id:
<asp:Label ID="idLabel" runat="server" Text='<%# Eval("id")
%>'></asp:Label><br />
name:
<asp:Label ID="nameLabel" runat="server" Text='<%#
Bind("name") %>'></asp:Label><br />
memo:
<asp:Label ID="memoLabel" runat="server" Text='<%#
Bind("memo") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete"
Text="Delete">
</asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New"
Text="New">
</asp:LinkButton>
</td>
</tr>
</table>

</ItemTemplate>

</asp:FormView>
====================

note that I use the

<table width="200" style="table-layout: fixed; word-break:break-all" >
<tr>


to wapper the ItemTemplate content.......

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "sck10" <[email protected]>
| Subject: ASP.NET 2.0: Label Problem using formview
| Date: Mon, 19 Dec 2005 18:08:27 -0600
| Lines: 16
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 189.202.185.135.in-addr.arpa 135.185.202.189
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365836
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello,
|
| I am pulling data from a SQL Server table. One field that is (varchar
4000)
| is used to show notes. I am using a FormView for showing and editing the
| data. When the form is in Item view, the text runs together. All the
line
| breaks are missing. When I enter into Edit mode, the text is formatted as
| it was entered (line breaks).
|
| How can I fix this so that when in "Item" mode, the line breaks show?
|
| --
| Thanks in advance,
|
| sck10
|
|
|
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top