Solved

Formatting SS#

Posted on 2006-07-05
4
726 Views
Last Modified: 2012-05-05
Need to format Social Security number but the DataFormatString is not cmoing out right... I have {0:###-##-####}. The value in the DB is just a number, no dashes, but I want to display it as a SS#. I formatted the dates to show MM-dd-yyyy, so why isn't the SS# coming up?
0
Comment
Question by:marcivry
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17045751
It sounds like it might not be treating you value as a number. Take this as an example:

    int ss = 123456789;
    string formattedSS = string.Format("{0:###-##-####}", ss);

Or in VB:

    Dim ss As Integer = 123456789
    Dim formattedSS As String = String.Format("{0:###-##-####}", ss)
0
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 17045763
Where should your SS# appear? GridView?
0
 
LVL 14

Accepted Solution

by:
dfu23 earned 125 total points
ID: 17045771
The pound (#) signs are for displaying numeric data ... and even though the SS# is a bunch of numbers the dashes are what is throwing things off.

I would just split out the parts of the string as needed to make the display you want since the data will always be the same length:

mySSN.Substring(0, 3) + "-" + mySSN.Substring(3, 2) + "-" + mySSN.Substring(5);
0
 

Author Comment

by:marcivry
ID: 17050251
So, How should I code it? Is it within the script tags or should i do a code behind?
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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

706 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

16 Experts available now in Live!

Get 1:1 Help Now