Trailing empty space added when using Repeater and DataReader

A

Andrei Pociu

I use a Repeater which displays values from a DataReader (which gets them
from a SQL DB).
Everytime I'm using:

<%#DataBinder.Eval(Container.DataItem, "ColumnName")%>

....in the HTML code to output the values I get a trailing space after the
result, for example if I use the following:

Bla bla bla <%#DataBinder.Eval(Container.DataItem, "ColumnName")%>!

....and ColumnName has a value 'annoyed' I get the result:

Bla bla bla annoyed !

Thanks for your help.
 
E

Eliyahu Goldin

This is how it comes from the database when you have fixed length character
fields. Either use varchars or trim the spaces somewhere on the way.

Eliyahu
 
A

Andrei Pociu

You are right, as this doesn't happen with int type for example, but I
changed to varchar and still it has the space.
 
E

Eliyahu Goldin

Because they are already there. New records they won't have spaces. You can
run a simple update to trim spaces in the existent records.

Eliyahu
 
A

Andrei Pociu

I tried to edit them but it still wouldn't work. Only by deleting them and
adding them again it works.

Thanks for helping me.
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top