This is a migrated thread and some comments may be shown as answers.

RadGridNumericColumn not formatting to 2 decimal digits in the grid view

1 Answer 582 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 23 Aug 2011, 06:59 PM
I am experiencing a problem where i have set the dataformatstring on my radgridnumericcolumn to {0:c} and it is appearing with a bunch of decimal digits rather than just 2 , i have also set the decimal digits property to 2 and tried {0:c2} and allowrounding. When in edit mode it displays how i want to with just 2 decimal places but on the grid itself its displaying with more than 2.

here is an example of what is being used now :

COLUMN :
<telerik:GridNumericColumn DataField="Premium" DecimalDigits="2" DataFormatString="{0:c}" DataType="System.Decimal" ColumnEditorID="PremiumEditor" HeaderText="Premium" UniqueName="Premium" SortExpression="Premium" >
                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                 <ItemStyle HorizontalAlign="Left" Font-Names="Verdana" Font-Size="11px"></ItemStyle>
</telerik:GridNumericColumn>

EDITOR:
<telerik:GridNumericColumnEditor ID="PremiumEditor" runat="server">
               <NumericTextBox>
                   <NumberFormat DecimalDigits="2" />
                   <NumberFormat AllowRounding="true" />
                   <NumberFormat KeepNotRoundedValue="false" />
               </NumericTextBox>
</telerik:GridNumericColumnEditor>

Any idea what might be happening? Again it looks exactly how i want in edit mode but not on the grid itself

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 26 Aug 2011, 09:33 AM
Hi Andrew,

Could you confirm that the field in your database is numeric/float/decimal/real ?
Because if it is string(nvarchar) that holds number it still will be editable using the RadNumericTextBox, but formatting in the column will not work properly.

Additionally you could try to use template column like "UnitPrice" in this demo and format it in the Eval function:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/alleditablecolumns/defaultcs.aspx

Regards,
Vasil
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or