Question Phone number format

andimanro

Member
Joined
Jun 7, 2010
Messages
18
Programming Experience
1-3
does anyone know how to change phone number column format for example : 012345678912 into 0123 4567 8912 format in a gridview ?

Thanks in advance
 
Last edited:
There isn't really nay way to do it automatically. If it was actually a number then you could simply assign the appropriate format string to the DefaultCellStyle.Format property. You can't use a number though, because that would remove leading zeroes, and you can't format strings. Two options would be:

1. Add an extra column to your DataTable and loop through, converting each existing value manually. Display that new column in your grid instead of the original. When the user enters data, format it manually if it needs it and then copy the data to the original column, minus the formatting.

2. Create your own custom column and cell type that performs the transformation internally and then use them in place of the default text box column and cell.
 
Back
Top