Textbox Web Control

K

Karen A Hodge

Hello,
I have a SQL Server table which has several columns that are of type
varchar.
I have bound textboxes for this table on a Web form. The form is used for
data entry.

Question: How do I get rid of the trailing blanks on the control?

The blanks are annoying because you can't insert characters because the
maxlength has been reached. Right now I have to delete the trailing blanks
before I can successfully edit the field.

This seems like a trivial thing to me, but I can't figure out how to do it.

Thanks
 
A

Alessandro Zifiglio

Textbox1.Text.Trim
This should trim trailing spaces towards the left and right of your text
thats within your textbox control.
 
N

Nikerz Inc

Hi Karen,

Would you be able to share your binding code, I'm having a hard time finding
information to bind textboxes to datasets and update them back to a
database!

Thx!
 
K

Karen Hodge

Thank you for your reply.

I bind my textboxes at design time.
This is my custom databinding expression:
DataBinder.Eval(MembersDS,
"Tables[spSelectMember].DefaultView.[0].Title")

At what point do you suggest that I trim the data?
 
A

Alessandro Zifiglio

Karen, you can trim it as you retrieve data, that is taking this to your
datalayer in your sql statement, use the trim function in sql like :
select trim(title) from bla
and then bind to your textbox.

Or after having bound your textbox that is after it is filled with data use
the trim function of you textbox like i showed you in my previous post.

On a side node, to avoid such situation you should always trim the data
before storing it into your database.
 
N

Nikerz Inc

Hi there,

I'd suggest to trim the data while you load it from your SQL string
something like select ltrim(memeber) from employee That should work, would
you be able to share more code, I'm trying to bind a from that I enter
customer information into to my database, I'm having a problem actually
binding the textboxes to my dataset.

Thanks!
 
K

Karen Hodge

Alessandro,
Thanks, I figured that out as a result to your first posting. I have not
had that problem before. The data in this table was imported from a
Foxpro table, which explains why the data was not trimmed in the first
place.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top