Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Formatting SS#

Posted on 2006-07-05
4
Medium Priority
?
741 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
[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
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 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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 …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

715 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