Designer Setting for Trimming White Space on Varchar (string) Data Types

Posts   
 
    
Gianc1412
User
Posts: 40
Joined: 30-Oct-2007
# Posted on: 02-Feb-2011 06:40:30   

I'm using version 2.6 but I do have 3.0 if I need to upgrade. I'm using self servicing.

Is there a way to set an option in the designer to generate code that will trim all varchar input parameters during an insert or update.

I'm binding a grid directly to a LLBLGENProDataSource and white spaces are being caught by the text inputs automatically generated by the grid.

There will be alot of work to manually trim in code behind during an ItemCommand event... etc... because I'm not using any code behind on these grids as of now.

It would be great if an option is available in the designer to "magically" do this. If not I guess I could override the entity's properties in a partial class and trim there?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 02-Feb-2011 09:55:40   

It's not build in, but you can build it in simple_smile

There are several options. - Create a typeconverter, which simply converts from string to string, so there's no type conversion going on, but it simply trims off the spaces. See SDK documentation how to write a typeconverter and also the sourcecode of the shipped example type converter to get started. You can bulk-assign a type converter by using the plugin

  • another way to deal with this is in the entity. Create a partial class of CommonEntityBase, and override PreProcessValueToSet. In there, check whether the fieldToSet.DataType is typeof(string). If so, trim valueToSet by casting it to string first, like:
if(valueToSet!=null)
{
    valueToSet = ((string)valueToSet).Trim();
}

Frans Bouma | Lead developer LLBLGen Pro