Solved

Format SSN

Posted on 2007-04-09
4
917 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now