Problem with spaces in values of the DataTextField property of datagrid control

C

chorus_charms

Hi,

I am using a datagrid control to display the values from a database
table.

I have used a Button Column with the DataTextField Column set to the
field in the db table, from where I need to populate values. It is
basically a Report Name.
The problem is that if the Report name contains spaces, the same is
rendered on the Datagrid column without spaces.

In other words, if I saved a report name as "joe black" or "joe
black" or "joe black", it is always displayed as
"joe black" on the grid control.
The db table saves the name correctly.

Can anyone suggest some way to overcome this problem??

Thanks,
Sadhvi M
 
C

CaffieneRush

Your problem lies with the way browsers interpret whitespace in HTML.
Most browsers would render 1 space even though there are multiple
spaces in the source HTML.

A suggestion to preserve spaces is to replace each space in the report
name with the   html entity. You do the replacement after reading
the values out of the database and before doing a databind on the
gridview.

Another suggestion to preserve spaces is to enclose the report name
with the <pre> tag.

Andy.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top