Hi,
I have a column field in SQL Server database which is a string file, which contain phone number (11 digits, for example: 12223334444). In RadGrid, I used following code to format the number to display in RadGrid as a proper telephone number:
Would you please tell me how to format and export string of telephone number to excel properly?
Thanks
LamK
I have a column field in SQL Server database which is a string file, which contain phone number (11 digits, for example: 12223334444). In RadGrid, I used following code to format the number to display in RadGrid as a proper telephone number:
protected void RadGridResult_ItemDataBound(object sender, GridItemEventArgs e)
{
//Format string to phone number.
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem) e.Item;
Object ob = item["ConfirmationLogPhone"].Text;
if (!Convert.IsDBNull(ob))
{
Int64 iParsedValue = 0;
if (Int64.TryParse(ob.ToString(), out iParsedValue))
{
TableCell cell = item["ConfirmationLogPhone"];
cell.Text =
String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:#-(###) ###-####}", new object[] { iParsedValue });
}
}
}
}
However, when I export the grid to excel, the number is display merely just a string (Ex: 12223334444). MS Excel even report error that "Number stored as text field" on every cell in the column.
Would you please tell me how to format and export string of telephone number to excel properly?
Thanks
LamK