DataFormatString="{0:D}"
DataFormatString="{0:#####}"
...however, these dont work, my value keeps displaying as: 70,117
whats up?
thanks!
matt
22 Answers, 1 is accepted

the value looks fine when listed as a row in the grid. but when its in the edit-form, it has commas.
thanks
matt

Try the following code snippet to achieve the desired scenario.
ASPX:
<telerik:GridNumericColumn DataField="RollNo" HeaderText="NumCol" UniqueName="NumCol"></telerik:GridNumericColumn> |
CS:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) |
{ |
GridEditableItem edititem = (GridEditableItem)e.Item; |
RadNumericTextBox numtxtbx = (RadNumericTextBox)edititem["NumCol"].Controls[0]; |
numtxtbx.NumberFormat.GroupSeparator = ""; |
} |
} |
Thanks
Shinu.

that seems like hack. hooking into that event handler should *not* be necessary to achieve such a basic necessity such as proper numeric formatting.
after all, what is the DataFormatString property for, if not this?
telerik -- is this a known bug w/ the DataFormatString property??
thanks
matt

should one not be able to use the NumericColumn's DataFormatString property to format it in both grid-list view, and in edit-form view?
for example, i am using the NumericColumn for a zip code field -- one does not use commas in a zip.
it does not seem logical or reasonable to have to hook into the ItemDataBound event to fix this. is this a bug?
Try the code below:
<telerik:GridNumericColumn DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" UniqueName="UnitPrice" DataType="System.Decimal" DataFormatString="{0:F0}"> |
</telerik:GridNumericColumn> |
BoundField.DataFormatString Property
All the best,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I'm using version 2008.1.415.35 of the controls.
Telerik, can you confirm whether this is a bug or confirm which version the functionality behaves as expected?
Thanks !!!!
Can you try our latest version instead?
Sincerely yours,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I have the same problem using 2008.2.826.35.
I'm using programatically created columns, and my numeric columns are set up as follows :
GridNumericColumn gn =
new GridNumericColumn();
gn.DataType = typeof(decimal);
gn.NumericType = NumericType.Number;
gn.DataFormatString = "{0:n2}";
gn.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
gn.MaxLength = maxLength;
gn.DataField = uniqueName;
gn.ReadOnly = (RO == "1");
The column will in my case be readonly, and it displays with 4 decimals and is left-justified.
The same approach seems to work perfectly with date-columns.

The latest version appears to have the issue corrected.
Can anyone else confirm?
Please try the attached sample website and let us know whether it works as expected.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

What doesn't work with read-only columns?
Actually the HtmlEncode property can prevent the DataFormatString to work as expected. Since Q2 SP2 release it has been set to false as default.
Greetings,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Formatting of read-only columns doesn’t work in InPlace edit mode.
<MasterTableView AutoGenerateColumns="False" commanditemdisplay="Top"
datakeynames="LineNumber" editmode="InPlace">
<telerik:GridNumericColumn DataField="OutstandingQuantity"
DataType="System.Decimal" HeaderText="Outstanding"
SortExpression="OutstandingQuantity" UniqueName="OutstandingQuantity"
DataFormatString="{0:n}" ReadOnly="True">
<ItemStyle HorizontalAlign="Right" />
</telerik:GridNumericColumn>
Add this column to grid, enter edit mode, column will be displayed as 935.59000000000000000000.
Telerik version is 2008.2.1001.35.
You can customize the embedded RadNumericTextBox as shown below:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
GridDataItem item = e.Item as GridDataItem; |
if (e.Item.IsInEditMode && item != null) |
{ |
RadNumericTextBox textBox = item["OutstandingQuantity"].Controls[0] as RadNumericTextBox; |
textBox.NumberFormat.AllowRounding = true; |
textBox.Type = NumericType.Number; |
} |
} |
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Thanks. I know how to customise it, but it should work as standard without customisation.
Regards, Roman.
The standards should be to not have a NumberFormat-GroupSeparator, which is mathematically incorrect in my opinion.
A property to add a group seperator would make sense. But working around to remove it... :o/
A comma is indicating decimals... A dot would be acceptable too...
3.141=3,141
<> 3141
(For me, it's of the same order of people who say 2+2*2=8 (correct answer is 6); maths 101)
Thank you for your suggestion. However I'm afraid we can't afford to alter this behavior due to breaking change concerns. I believe that you will agree with me that the single line that is needed to disable grouping separator, is straightforward enough.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

And yes, "the single line that is needed to disable grouping separator, is straightforward enough.".
But, would it be possible to add that property directly for the gridnumericcolumn? (Instead of having to find the autogenerated numerictextbox in the itemdatabound event).
I passed your suggestion to our developers for future consideration. In the meantime I recommend you use our declarative column editors instead of using code-behind approach:
<telerik:RadGrid ID="RadGrid1" runat="server" ...> |
<MasterTableView ...> |
<Columns> |
<telerik:GridNumericColumn ColumnEditorID="NumericEditor1" DataField="MyValue" /> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
<telerik:GridNumericColumnEditor ID="NumericEditor1" runat="server"> |
<NumericTextBox> |
<NumberFormat GroupSeparator="" /> |
</NumericTextBox> |
</telerik:GridNumericColumnEditor> |
Built-in column editors
As a sign of gratitude for your suggestion I updated your Telerik points.
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

Guess that way is very straightforward too..

i am not able to set the dataformatstring for radgrid.
i can see that the format string property is assigned -- as the filter values for each column are getting changed depending upon the column type i have assigned to it. but for some reason none of the data is displayed in correct format.
i cannot set the columns at the design mode it self as, the columns are generated differently for different cases
my code looks something like this
rgList.Datasource = dt.DefaultView -- this contains the number of columns and the column property.
in columncreted event i am trying to set the dataformatstring property
Dim formatString As String = String.Empty
If e.Column.ColumnType = "GridBoundColumn" Then
'when columns are created
Dim col As GridBoundColumn = CType(e.Column, GridBoundColumn)
col.HeaderText = colUniqueNames(colIndex)
col.UniqueName = colUniqueNames(colIndex)
If Not GetDataType(col.UniqueName) Is Nothing Then
col.DataType = GetDataType(col.UniqueName) --- here it sets the property as decimal or integer and so on
End If
col.DataFormatString = SetFormatString(col.UniqueName) -- here it assigns the property for format as {0:N} or {0:p}
End If
colIndex += 1
If colIndex = iColCount + 1 Then
colIndex = 0
End If
Please do help me out as i am stuck with this problem for long time.
thank you for your help.
Raghav.
