Edit this page

Data Formatting

GridViewDataColumn and GridViewComboBoxColumn allow you to format the displayed data by specifying an appropriate format string and assigning it to the DataFormatString property for the column.

[XAML] Example 1: Set DataFormatString property of DateTime column

<telerik:GridViewDataColumn DataMemberBinding="{Binding OrderDate}"
                Header="Order Date"
                UniqueName="OrderDate"
                DataFormatString="{} {0:dd, MMM, yyyy}" />

{} is the XAML escape sequence which allows subsequent values in the attribute to be interpreted as a literal.. You can find more information in the MSDN Escape Sequence article.

[C#] Example 1: Set DataFormatString property of DateTime column

((GridViewDataColumn)this.radGridView.Columns["OrderDate"]).DataFormatString = "{0:dd, MMM, yyyy}";
// or
((GridViewDataColumn)this.radGridView.Columns["OrderDate"]).DataFormatString = "dd, MMM, yyyy";

[VB.NET] Example 1: Set DataFormatString property of DateTime column

DirectCast(Me.radGridView.Columns("OrderDate"), GridViewDataColumn).DataFormatString = "{0:dd, MMM, yyyy}"
' or
DirectCast(Me.radGridView.Columns("OrderDate"), GridViewDataColumn).DataFormatString = "dd, MMM, yyyy"

Figure 1: DateTime column with custom DataFormatString

DateTime column with custom DataFormatString

The DataFormatString property uses the string.Format method. To learn more, check the string.Format MSDN article.

To learn more about formatting visit the Formatting Overview chapter in MSDN.

See Also