Forum Moderators: open
I'm trying to work out a way to display alphabetic characters that occassionally appear in phone numbers (for instance, 866-555-BIKE). They way I have it setup now they are simply ignored. Here's what I currently have:
<%# String.Format("{0:###-###-####}", Convert.ToDecimal(DataBinder.Eval(Container.DataItem, "ItemValue").ToString().Replace("-","")))%>
I'm not trying to convert the alpha characters to numbers or anything, just display them.
I'd appreciate any pointers.
You could use the following:
<%
string myString = (DataBinder.Eval(Container.DataItem, "ItemValue").ToString().Replace("-",""));
response.write(myString.Substring(0, 3) + "-" + myString.Substring(3, 3) + "-" + myString.Substring(6, 4));
%>