Formatting the phone nos in the column in the datagrid

T

TJ

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
 
E

Elton W

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
(e-mail address removed)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top