Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Format SSN

Not sure how to do this:
In the database, there's a table that holds the SSN format. For example, client1 might want their SSNs to look like 999-99-9999. Client2 might want their SSN to look like 999/99/9999. Client3 might want their SSN to look like 99-999-9999.

*** So the separater and the # of digits to the side of the separators might change.
The SSNs are stored as 999999999 in the database. Before displaying them in the gridview, I need to format them based on what  the client wants them displayed...

SO I read 111228888, format, for example is 99-999-9999...then what? I think i need a class/routine to maybe read the format from the database, maybe parse the 9's before and after the separator, maybe count the digits and then parse the actual SSN like that?? any ideas?
ASKER CERTIFIED SOLUTION
Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Camillia

ASKER

so, read the format from the database, stick it in ToString?

Like this: 999/99/9999  :   111223333.ToString("999/99/9999") -- > 111/22/3333
?

Yes.  Of course, in your actual code you won't be using constants.  It will probably be more like

YourDataReader("columnName").ToString(formatYouLoadedForUser)
thanks.