Can anyone see why the following code isn't working? I'm trying to format a phone number in a datagrid like (201) 555-1234 but all I get is 2015551234.
<ASPATAGRID ID="dgTest" RUNAT="server" AUTOGENERATECOLUMNS="False">
<COLUMNS>
<ASP:BOUNDCOLUMN DATAFIELD="Phone" HEADERTEXT="Phone" DATAFORMATSTRING="{0###) ###-####}" />
</COLUMNS>
</ASPATAGRID>
I've had this problem before when the datafield wasn't a string. Changing the field type to VarChar(10) has solved the problem in the past, but that isn't an option on this one.
The phone field is actually a couple of Integer columns, which I'm trying to convert in the select statement like this:
SELECT Cast((Convert(Char(6),ANI) + Convert(Char(4),Exchange)) AS Char(10)) AS Phone
I can actually make it work if I do all of the formatting in the select statement and just leave out the dataformatstring in the datagrid, but shouldn't the datagrid be able to do the formatting?
Is there a better way to do this? Anyone know why it doesn't work as advertised?
Any help would be appreciated.
JRL
<ASPATAGRID ID="dgTest" RUNAT="server" AUTOGENERATECOLUMNS="False">
<COLUMNS>
<ASP:BOUNDCOLUMN DATAFIELD="Phone" HEADERTEXT="Phone" DATAFORMATSTRING="{0###) ###-####}" />
</COLUMNS>
</ASPATAGRID>
I've had this problem before when the datafield wasn't a string. Changing the field type to VarChar(10) has solved the problem in the past, but that isn't an option on this one.
The phone field is actually a couple of Integer columns, which I'm trying to convert in the select statement like this:
SELECT Cast((Convert(Char(6),ANI) + Convert(Char(4),Exchange)) AS Char(10)) AS Phone
I can actually make it work if I do all of the formatting in the select statement and just leave out the dataformatstring in the datagrid, but shouldn't the datagrid be able to do the formatting?
Is there a better way to do this? Anyone know why it doesn't work as advertised?
Any help would be appreciated.
JRL