New to Telerik UI for ASP.NET AJAX? Download 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.
     <telerik:GridNumericColumn DataField="MyYear" HeaderText="My Year" UniqueName="MyYear"  DataType="System.Int32" ColumnEditorID="NumericEditor1">
    </telerik:GridNumericColumn>
    
  2. Create a GridNumericColumnEditor containing a NumericTextBox.

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

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

    See Also

In this article