473,503 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help displaying text in an asp.net table

I am using an asp.net table to display postings in a classifieds website.

This is a section of the HTM I am using...

<asp:table id="tblAdvert" Width="466px" Height="78px" runat="server"
BackColor="Gainsboro" BorderStyle="Solid" BorderWidth="1px"
BorderColor="MidnightBlue" GridLines="Both" CellSpacing="0">
<asp:TableRow>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
...
<asp:TableRow>

And then I fill the table like this (in the code-behind) ...
tblAdvert.Rows(3).Cells(0).Text = advert.Description

The problem is that the text all gets displayed in one paragraph, even
though the user might have added lines when they entered the posting.

So I tried this...
tblAdvert.Rows(3).Cells(0).Text = "<pre class=advertdescription>" &
advert.Description & "</pre>"

This expands the table so that it stretches out, and the user has to scroll
horizontally to see the whole posting.

Any suggestions ? Thanks,
Craig
Nov 19 '05 #1
2 1250
You are either going to want to force your users to use HTML tags in
their description, or do a replace on the linebreaks, and push in <br> tags.

Something like Description.Replace(Environment.NewLine,"<BR>")

Also, I'd probably be using a label control instead of picking the table
cell through code. That way you seperate out the logic from the UI a
little more.

Lowell


Craig HB wrote:
I am using an asp.net table to display postings in a classifieds website.

This is a section of the HTM I am using...

<asp:table id="tblAdvert" Width="466px" Height="78px" runat="server"
BackColor="Gainsboro" BorderStyle="Solid" BorderWidth="1px"
BorderColor="MidnightBlue" GridLines="Both" CellSpacing="0">
<asp:TableRow>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
...
<asp:TableRow>

And then I fill the table like this (in the code-behind) ...
tblAdvert.Rows(3).Cells(0).Text = advert.Description

The problem is that the text all gets displayed in one paragraph, even
though the user might have added lines when they entered the posting.

So I tried this...
tblAdvert.Rows(3).Cells(0).Text = "<pre class=advertdescription>" &
advert.Description & "</pre>"

This expands the table so that it stretches out, and the user has to scroll
horizontally to see the whole posting.

Any suggestions ? Thanks,
Craig

Nov 19 '05 #2
Thanks Lowell.

"Description.Replace(Environment.NewLine,"<BR> ")" worked !

"Lowell Heddings" wrote:
You are either going to want to force your users to use HTML tags in
their description, or do a replace on the linebreaks, and push in <br> tags.

Something like Description.Replace(Environment.NewLine,"<BR>")

Also, I'd probably be using a label control instead of picking the table
cell through code. That way you seperate out the logic from the UI a
little more.

Lowell


Craig HB wrote:
I am using an asp.net table to display postings in a classifieds website.

This is a section of the HTM I am using...

<asp:table id="tblAdvert" Width="466px" Height="78px" runat="server"
BackColor="Gainsboro" BorderStyle="Solid" BorderWidth="1px"
BorderColor="MidnightBlue" GridLines="Both" CellSpacing="0">
<asp:TableRow>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
...
<asp:TableRow>

And then I fill the table like this (in the code-behind) ...
tblAdvert.Rows(3).Cells(0).Text = advert.Description

The problem is that the text all gets displayed in one paragraph, even
though the user might have added lines when they entered the posting.

So I tried this...
tblAdvert.Rows(3).Cells(0).Text = "<pre class=advertdescription>" &
advert.Description & "</pre>"

This expands the table so that it stretches out, and the user has to scroll
horizontally to see the whole posting.

Any suggestions ? Thanks,
Craig

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1487
by: suzy | last post by:
it seems like a simple enough problem, but i need some help...... i have a table of messages (like newsgroup messages) in sql server. my application will allow people to read threads/messages...
9
2324
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There...
2
2500
by: Susan Bricker | last post by:
Greetings! Still the same application (as previous posts). I worked on the app while at work (don't tell my boss ... cause this is just for fun and not work related) and the form was working,...
0
1708
by: Fronky | last post by:
Hope someone can help. I am still learning, so no laughing please. I am displaying records from a database using Response.Write(""); instead of the usual datagrid method. I am doing it this way...
0
238
by: TN Bella | last post by:
This may be a double post... I appreciate all the help I have gotten on here - thank you! So with that in mind, I figured I would try another post! :) I need to reformat the following...
9
4545
by: Cogito | last post by:
My program builds several tables using inner HTML. All the tables are displayed only when the program terminates. How can I make it display one table at a time and then wait for a click before...
2
3135
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
7
3295
by: Dave | last post by:
Hello All, These one may be a bit tricky, and what I'd like to do may not even be possible. I would love to hear any ideas you guys have for solving this. Here is the situation: I have a form...
11
2403
by: dba | last post by:
Have been displaying data from database using html for some time but just recently trying to display data back to "form". Can't find answer. <form method="post" action="<?php echo $PHP_SELF;?>">...
4
1775
by: Yonih | last post by:
So I am trying to get this Calculator to work. It needs to take in a vaule, and select a shipping Everythin works great except the shipping part. I need it to take the shipping value and add it to...
0
7201
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7456
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.