We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

IGridColumnBuilder Format(string content) does not format string types


I want to format (e.g. (123) 456-7890) the values in the Telephone field when displayed in the grid. Below is my code in cshtml. Note that Telephone has a "string" data type.

@{ Html.Syncfusion().Grid<AutoFormatting>("FormatGrid")





.Column( column =>


column.Add(c => c.Telephone)


                                   .Format("{0:(###) ###-####}");



Currently, formatting does not work for string types. Do you have any work around aside from creating another field with int or int64 type?


1 Reply

AM Abdul Matin M Syncfusion Team June 21, 2013 12:16 PM UTC

Hi Ronaldo,


Thanks for using Syncfusion Products.


Your requirement to format string data type can be achieved using QueryCellInfo event. In QueryCellInfo event we have did formatting by converting the string to integer and again converted the result back to string and displayed the formatted string in the grid. Could you please refer the below code snippet.



public void QueryCellInfo(GridTableCell<AutoFormatting> cell)


            if (cell.TableCellType == GridTableCellType.RecordFieldCell || cell.TableCellType == GridTableCellType.AlternateRecordFieldCell)


                if (cell.Column.MappingName == "Telephone")


                    cell.Text = Convert.ToInt64(cell.Data.Telephone).ToString("(###) ###-####");





For your convenience we have attached a sample. Could you use that sample and get back to us if you have any queries.


Let us know if you have any other concerns.



Abdul Matin M.


Live Chat Icon For mobile
Up arrow icon