views:

340

answers:

1

Hi All,

In the application I am working on, I have a TableAdapter, and a RadGridView (Telerik control - their version of the DataGridView). The TA is pulling different elements from our database, including PhoneNumber, which is stored as varchar.

In my GridView, I would like to display this format as (123) 456-7890. Unfortunately, I have been unable to accomplish this.

I have tried the following (which is Telerik's recommended method):

radGvUsers.Columns["PhoneNumber"].FormatString = "{0: (###) ###-####}";

This results in the value displaying as it does in the db: 1234567890

I know (ok, I think) this is because it is stored as varchar and needs to be converted to a number, but I don't know how or where (i.e. at the TA or GridView level) best to do this.

Any suggestions? Feel free to ask more questions if I did not supply enough info!

+1  A: 

You can convert the string to a numeric in the SQL Statement

Select Convert(bigint, PhoneNumber) AS PhoneNumber FROM sometable
David Stratton