Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i remove the trailing white space on DataBind?

Status
Not open for further replies.

mrgulic

Technical User
Sep 18, 2001
248
US
I have the following code that gets data from SQL2K5. I have tried setting the ANSI padding is FALSE and i have tried nchar and nvarchar, but they all keep the space. I read that MS recomends leaveing the whitespace and removing it at the application level, which is why I am here.

Code:
ddl_deviceType.DataSource = dbu.GetSqlDataReader(sqlDatasource, sqlCatalog, sqlSecurity, sqlSelect);
ddl_deviceType.DataValueField = "device_type_id";
ddl_deviceType.DataTextField = "device_type_name";
ddl_deviceType.DataBind();
ddl_deviceType.Items.Insert(0, new ListItem("- Select Device Type -"));

I have tried

Code:
ddl_deviceType.DataTextField = "device_type_name".Trim();

but it didnt make a difference.

Thanks for your insight.
 
You could try in your SELECT statement using
RTRIM(fieldname) which would remove any trailing spaces.

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top