Formatting the phone nos in the column in the datagrid

Discussion in 'ASP .Net Datagrid Control' started by TJ, May 13, 2005.

  1. TJ

    TJ Guest

    I want to format the phone nos displayed in the column of the datagrid
    to ###-###-####

    i tried the following in the ItemCreated event but is not working

    If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType =
    ListItemType.Item Then
    e.Item.Cells(3).Text =
    (e.Item.Cells(3).Text).Format("###-###-####")
    End If

    Any suggestion??

    Thanks
     
    TJ, May 13, 2005
    #1
    1. Advertising

  2. TJ

    Elton W Guest

    Hi TJ,

    You can directly format data in datagrid's html code.

    In BoundColumn:
    DataFormatString="{0:###-###-####}"

    In TemplateColumn:
    <%# DataBinder.Eval
    (Container.DataItem, "DataField", "{0:###-###-####}") %>


    HTH

    Elton Wang



    >-----Original Message-----
    >I want to format the phone nos displayed in the column of

    the datagrid
    >to ###-###-####
    >
    >i tried the following in the ItemCreated event but is not

    working
    >
    >If e.Item.ItemType = ListItemType.AlternatingItem Or

    e.Item.ItemType =
    >ListItemType.Item Then
    > e.Item.Cells(3).Text =
    >(e.Item.Cells(3).Text).Format("###-###-####")
    > End If
    >
    >Any suggestion??
    >
    >Thanks
    >
    >.
    >
     
    Elton W, May 13, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bakkurudeen Ali J

    VHDL - Query about Division of two Nos

    Bakkurudeen Ali J, Nov 24, 2004, in forum: VHDL
    Replies:
    2
    Views:
    2,114
    Jim Lewis
    Nov 24, 2004
  2. Zahoor
    Replies:
    1
    Views:
    811
    Darryl L. Pierce
    Nov 15, 2003
  3. Robocop
    Replies:
    2
    Views:
    1,768
    Dale King
    Feb 23, 2004
  4. chen selina
    Replies:
    0
    Views:
    887
    chen selina
    Jul 7, 2010
  5. Rene Ivon Shamberger

    convert Phone Letters to Phone numbers

    Rene Ivon Shamberger, Dec 4, 2012, in forum: C++
    Replies:
    5
    Views:
    390
Loading...

Share This Page