Solved

Format SSN

Posted on 2007-04-09
4
925 Views
Last Modified: 2008-03-10
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?
0
Comment
Question by:Camillia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 18875572
This should not be that complicated.  

123456.ToString("0-0-000-0")
produces
"1-2-345-6"

so all you need is the data to format and the format string, and the framework does the rest.
0
 
LVL 7

Author Comment

by:Camillia
ID: 18875600
so, read the format from the database, stick it in ToString?

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

0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 18875632
Yes.  Of course, in your actual code you won't be using constants.  It will probably be more like

YourDataReader("columnName").ToString(formatYouLoadedForUser)
0
 
LVL 7

Author Comment

by:Camillia
ID: 18875651
thanks.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question