Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a database with phone number nvarchar, and a cell as numeric.

I formatted both as ###-###-####.

I have two question.

Question 1.

When a employee enter the number how to make except the format?

Question 2.

when a employee go to save it gives an error message can't save with the dashes.

Tried both neither works.

Is this a asp.net /c# problem
or database issues.

So I will know what to research.
Posted
Updated 6-Dec-10 6:07am
v2
Comments
fjdiewornncalwe 6-Dec-10 12:19pm    
What do you mean by "phone number nvarchar, and cell as numeric"?
Is "phone number" an input parameter or something like that, or is it the field in the table?
What is the "cell"?
postonoh 6-Dec-10 12:40pm    
I am trying both types in the database to see which saves with the dashes and cell is cell phone my mistake thanks.

Just Google or use CodeProject search for Masked textbox!
 
Share this answer
 
Well, we could help you more if you actually gave us useful information. You say it gave you an error message... what was the exact error message? Also, post the code you're using and the sample data so we know exactly what you're trying to do.

My guess is you are trying to insert a string value into a numeric field. You'd have to remove the dashes, parse the string (perhaps as Decimal?), then insert that value into the numeric field. Without more information, that's the best guess I can give you.

Like another poster mentioned, use a masked textbox, or you can create multiple textboxes and put a validator on each of them to ensure they are in the right format. Personally, I'd probably put a regular expression validator on a single textbox and allow the user to enter multiple formats for their phone number.
 
Share this answer
 
I think you can handle this on your presentation layer. Instead of having one textbox for phone number, try with 3 textboxes separated by "-" with character limits of 3, 3 and 4 respectively.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900