Trailing empty space added when using Repeater and DataReader

  • Thread starter Thread starter Andrei Pociu
  • Start date Start date
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.
 
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
 
You are right, as this doesn't happen with int type for example, but I
changed to varchar and still it has the space.
 
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
 
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

Back
Top