Re: number format

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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 <help@xxxxxxx> wrote:

Maybe because phone field is coming as varchar??
Any ideas
tks

JFB

"JFB" <help@xxxxxxx> wrote in message
news:%23DIBn8nAHHA.3560@xxxxxxxxxxxxxxxxxxxxxxx
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" <MortenWennevik@xxxxxxxxxxx> wrote in message
news:op.timwoeyfklbvpo@xxxxxxxx
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 <help@xxxxxxx> wrote:

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]
.



Relevant Pages

  • Re: Multiple date formats in a Table
    ... John Nurick, which you seem to intimate that I should ... I shall do some coding and experimentation in the next ... in UK format. ... compilation of a db relating to family genealogy, ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Long Integer truncates 0 at beginning of number
    ... I don't think you need to redo all your coding. ... you use the Format function or property as ... If you want to change it to a string: ... Is there anything I can do to keep the field type long? ...
    (microsoft.public.access.gettingstarted)
  • Re: Format numbers e.g. 1 -> 1st, 12 -> 12th, 23 ->23rd
    ... Is there anything in the framework that will format a number's 'order' ... Happy coding! ... Morten Wennevik [C# MVP] ...
    (microsoft.public.dotnet.framework)
  • Re: Multimedia Compression in a nutshell
    ... Compression means getting shorter output, ... which again means that you need an entropy coding step. ... A container format is not a format that contains half-encoded values. ...
    (comp.compression)
  • Re: Any sample code to test the encoding of a text file?
    ... If, after you have read the file, find out that it is in another format, convert the file from one encoding to another. ... Happy Coding! ... Morten Wennevik [C# MVP] ...
    (microsoft.public.dotnet.languages.csharp)