473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

number format

JFB
Hi all,
How can I format a fax number as 888-333-444?
The number is coming from database as 8883334444
<ItemTemplate>
<%#container.dataItem("cfax")%>
</ItemTemplate>

Tks

JFB
Nov 7 '06 #1
6 3663
Hi JFB,

I'm sure there is a better method, and using DataBinder.Eval you should be
able to format the number using something like

[C#]
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>

However, I was unable to properly format the number that way so an
alternative method is to call a method that formats the number.

[C#]
<%# Format(DataBinder.Eval(Container.DataItem, "fax")) %>

Where Format is defined as
public string Format(object value)
{
long n = Convert.ToInt64(value);
return n.ToString("###-###-####");
}

On Tue, 07 Nov 2006 05:58:16 +0100, JFB <he**@jfb.comwrote:
Hi all,
How can I format a fax number as 888-333-444?
The number is coming from database as 8883334444
<ItemTemplate>
<%#container.dataItem("cfax")%>
</ItemTemplate>

Tks

JFB



--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 7 '06 #2
JFB
Tks for you reply Morten,
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>
I try the above code but it's not showing the format in my datagrid and I
don't get any errors...
Any ideas??
Rgds

JFB


"Morten Wennevik" <Mo************@hotmail.comwrote in message
news:op.timwoeyfklbvpo@tr024...
Hi JFB,

I'm sure there is a better method, and using DataBinder.Eval you should be
able to format the number using something like

[C#]
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>

However, I was unable to properly format the number that way so an
alternative method is to call a method that formats the number.

[C#]
<%# Format(DataBinder.Eval(Container.DataItem, "fax")) %>

Where Format is defined as
public string Format(object value)
{
long n = Convert.ToInt64(value);
return n.ToString("###-###-####");
}

On Tue, 07 Nov 2006 05:58:16 +0100, JFB <he**@jfb.comwrote:
Hi all,
How can I format a fax number as 888-333-444?
The number is coming from database as 8883334444
<ItemTemplate>
<%#container.dataItem("cfax")%>
</ItemTemplate>

Tks

JFB



--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 7 '06 #3
JFB
Maybe because phone field is coming as varchar??
Any ideas
tks

JFB

"JFB" <he**@jfb.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Tks for you reply Morten,
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>
I try the above code but it's not showing the format in my datagrid and I
don't get any errors...
Any ideas??
Rgds

JFB


"Morten Wennevik" <Mo************@hotmail.comwrote in message
news:op.timwoeyfklbvpo@tr024...
Hi JFB,

I'm sure there is a better method, and using DataBinder.Eval you should be
able to format the number using something like

[C#]
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>

However, I was unable to properly format the number that way so an
alternative method is to call a method that formats the number.

[C#]
<%# Format(DataBinder.Eval(Container.DataItem, "fax")) %>

Where Format is defined as
public string Format(object value)
{
long n = Convert.ToInt64(value);
return n.ToString("###-###-####");
}

On Tue, 07 Nov 2006 05:58:16 +0100, JFB <he**@jfb.comwrote:
>Hi all,
How can I format a fax number as 888-333-444?
The number is coming from database as 8883334444
<ItemTemplate>
<%#container.dataItem("cfax")%>
</ItemTemplate>

Tks

JFB


--
Happy Coding!
Morten Wennevik [C# MVP]

Nov 7 '06 #4
I couldn't get it to work either, and it may be because it is not
identified as a number, but the other method should work.
On Tue, 07 Nov 2006 20:25:57 +0100, JFB <he**@jfb.comwrote:
Maybe because phone field is coming as varchar??
Any ideas
tks

JFB

"JFB" <he**@jfb.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Tks for you reply Morten,
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>
I try the above code but it's not showing the format in my datagrid and
I
don't get any errors...
Any ideas??
Rgds

JFB


"Morten Wennevik" <Mo************@hotmail.comwrote in message
news:op.timwoeyfklbvpo@tr024...
Hi JFB,

I'm sure there is a better method, and using DataBinder.Eval you should
be
able to format the number using something like

[C#]
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>

However, I was unable to properly format the number that way so an
alternative method is to call a method that formats the number.

[C#]
<%# Format(DataBinder.Eval(Container.DataItem, "fax")) %>

Where Format is defined as
public string Format(object value)
{
long n = Convert.ToInt64(value);
return n.ToString("###-###-####");
}

On Tue, 07 Nov 2006 05:58:16 +0100, JFB <he**@jfb.comwrote:
>>Hi all,
How can I format a fax number as 888-333-444?
The number is coming from database as 8883334444
<ItemTemplate>
<%#container.dataItem("cfax")%>
</ItemTemplate>

Tks

JFB


--
Happy Coding!
Morten Wennevik [C# MVP]



--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 8 '06 #5
JFB
Tks for reply Morten,
Either way I couldn't made it to work.
I'm using vb.net function

Function Format(ByVal value As Object)

Dim n As Long = Convert.ToInt64(value)

Return n.ToString("###-###-####")

End Function

ERROR: System.FormatException: Input string was not in a correct format. at
System.Number.ParseInt64(String s, NumberStyles style, NumberFormatInfo
info) at System.String.System.IConvertible.ToInt64(IFormatP rovider provider)
at System.Convert.ToInt64(Object value)

Any Ideas??
Tks

JFB
"Morten Wennevik" <Mo************@hotmail.comwrote in message
news:op***************@tr024.bouvet.no...
I couldn't get it to work either, and it may be because it is not
identified as a number, but the other method should work.
On Tue, 07 Nov 2006 20:25:57 +0100, JFB <he**@jfb.comwrote:
Maybe because phone field is coming as varchar??
Any ideas
tks

JFB

"JFB" <he**@jfb.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Tks for you reply Morten,
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>
I try the above code but it's not showing the format in my datagrid and
I
don't get any errors...
Any ideas??
Rgds

JFB


"Morten Wennevik" <Mo************@hotmail.comwrote in message
news:op.timwoeyfklbvpo@tr024...
Hi JFB,

I'm sure there is a better method, and using DataBinder.Eval you should
be
able to format the number using something like

[C#]
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>

However, I was unable to properly format the number that way so an
alternative method is to call a method that formats the number.

[C#]
<%# Format(DataBinder.Eval(Container.DataItem, "fax")) %>

Where Format is defined as
public string Format(object value)
{
long n = Convert.ToInt64(value);
return n.ToString("###-###-####");
}

On Tue, 07 Nov 2006 05:58:16 +0100, JFB <he**@jfb.comwrote:
>>Hi all,
How can I format a fax number as 888-333-444?
The number is coming from database as 8883334444
<ItemTemplate>
<%#container.dataItem("cfax")%>
</ItemTemplate>

Tks

JFB


--
Happy Coding!
Morten Wennevik [C# MVP]



--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 8 '06 #6
JFB
Never Mine Morten.. it was the empty phone field.
Tks
JFB
"Morten Wennevik" <Mo************@hotmail.comwrote in message
news:op***************@tr024.bouvet.no...
I couldn't get it to work either, and it may be because it is not
identified as a number, but the other method should work.
On Tue, 07 Nov 2006 20:25:57 +0100, JFB <he**@jfb.comwrote:
Maybe because phone field is coming as varchar??
Any ideas
tks

JFB

"JFB" <he**@jfb.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Tks for you reply Morten,
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>
I try the above code but it's not showing the format in my datagrid and
I
don't get any errors...
Any ideas??
Rgds

JFB


"Morten Wennevik" <Mo************@hotmail.comwrote in message
news:op.timwoeyfklbvpo@tr024...
Hi JFB,

I'm sure there is a better method, and using DataBinder.Eval you should
be
able to format the number using something like

[C#]
<%# DataBinder.Eval(Container.DataItem, "cfax", "{0:###-###-####}") %>

However, I was unable to properly format the number that way so an
alternative method is to call a method that formats the number.

[C#]
<%# Format(DataBinder.Eval(Container.DataItem, "fax")) %>

Where Format is defined as
public string Format(object value)
{
long n = Convert.ToInt64(value);
return n.ToString("###-###-####");
}

On Tue, 07 Nov 2006 05:58:16 +0100, JFB <he**@jfb.comwrote:
>>Hi all,
How can I format a fax number as 888-333-444?
The number is coming from database as 8883334444
<ItemTemplate>
<%#container.dataItem("cfax")%>
</ItemTemplate>

Tks

JFB


--
Happy Coding!
Morten Wennevik [C# MVP]



--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 8 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: martin.mrazek | last post by:
Hello, I wanted to install Number::Format module bud ended up with following error message. Does anybody have any suggestion what the cause could be?? Could that be due to presence of perldl in my...
1
by: Michelle Hillard | last post by:
Hi guys, would appreciate if you can shed some light on this. Sorry to be a pain, can you tell me what is wrong with the following: for /F %%i in ('dir /b /on c:\bcp\pc*.txt') do bcp...
0
by: johkar | last post by:
My XML and XSL is below. Also below is a textual representation of what I want to get out of the XML with XSL. For each Extension node in XML, I am only concerned with those nodes with...
2
by: Richard Haber | last post by:
I am using format-number(-1234.56,'#,##0.00;(#,##0.00)') in a stylesheet that works in every xsl processor (including MSXML2) except for the one in ..NET 1.1. I am expecting to see (1,234.56) as...
13
by: jm | last post by:
I am trying to use datepart to get the real name of the month like "April" or "APR" not just "4." I could not find it in the documentation. Sorry. Thank you.
1
by: crowl | last post by:
Hi all, I want to have a number in a certain format. I took a look in the msdn and was happy to find the format-number Function. This works fine. But unfortunately, I can't find the format...
5
by: Kamaluokeakua | last post by:
I have to write an application that deals with clients in multiple countries. The addresses, phone numbers, country id and currency information has to be stored into a database that allows for the...
6
by: Jovo Mirkovic | last post by:
Hi, I have to make a program which will generate 100,000 different ID numbers (for example 2345-9341-0903-3432-3432 ...) It must be really different, I meen it can not be a similar (like...
10
by: Dixie | last post by:
I am appending some new fields to a table in vba and when I append a number field with is a byte, it does not inherit any format. I want it to be the General Number format, but it is blank. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.