Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string.format problem

Status
Not open for further replies.

bopritchard

Programmer
Jan 27, 2003
199
US
this is my label control
Code:
<asp:label Runat=server text='<%# string.format("{0:(###) ###-####}", Container.DataItem("phonenumber"))%>' ID="lblPhoneNumber"></asp:label>

the data for phonenumber is 7044561237
but it keeps getting rendered to the page as 7044561237
why is the string.format not formatting?
 
NOTE that:
1. The # is for numbers !
2. You forgot a \ .

Container.DataItem("phonenumber") returns a string !

So:

Dim s As Double
Double.TryParse(Container.DataItem("phonenumber"), s)
String.Format("{0:(###) ###\-####}", s)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top