New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Remove Group Separator from GridNumericColumnEditor in RadGrid

How to

How can I remove the commas in a GridNumericColumn when I edit without using code-behind?  When I enter edit mode, the four digit item value contains a comma when it should contain no formatting.  For example, I have a year that should not contain a comma.  Is there a way to change the appearance in the editor? 

Description

The GridNumericColumn uses a RadNumericTextBox as an editor which contains a numeric format of "N" by default.  This causes the group separator to be commas in en-US culture.

Solution

In order to change the appearance of a GridNumericColumn during edit mode, use a GridNumericColumnEditor.  With this editor, the numericTextBox can be formatted to contain no separators with its NumberFormat.GroupSeparator property.  Here are the steps to adjust the style of the editor:

  1. Add a ColumnEditorID to a GridNumericColumn to reference the GridNumericColumnEditor.
ASPX
<telerik:GridNumericColumn DataField="MyYear" HeaderText="My Year" UniqueName="MyYear"  DataType="System.Int32" ColumnEditorID="NumericEditor1">
</telerik:GridNumericColumn>
  1. Create a GridNumericColumnEditor containing a NumericTextBox.

  2. Set the NumberFormat - GroupSeparator's value as an empty string.

ASPX
<telerik:GridNumericColumnEditor ID="NumericEditor1" runat="server">
   <NumericTextBox runat="server">
       <NumberFormat GroupSeparator="" DecimalDigits="0" />
   </NumericTextBox>
</telerik:GridNumericColumnEditor>

See Also