Solved

Formatting SS#

Posted on 2006-07-05
4
740 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

623 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