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

[Solved] Setting GridNumericColumn decimal digits

1 Answer 253 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 18 Feb 2010, 07:31 PM
I'm trying to use a GridNumericColumn in a Grid using InPlace editing.  The field is a decimal 18,10 in Sql Server. Length of 8 to left and 10 to right of decimal.  The field displays properly in both item and edit modes. However, when you click on the field to edit, the field cuts off to only 2 decimal places to the right.   I've tried several different things but haven't got it to work.  I figured there be a decimal postion property but don't see one. The line is listed below in its current format. But this isn't working properly.

                            <telerik:GridNumericColumn UniqueName="Reduction" SortExpression="Reduction" HeaderText="Reduction" DataField="Reduction" FooterText="NumericColumn footer" NumericType="Number" AllowRounding="false" DataType="System.Decimal" KeepNotRoundedValue="true" DataFormatString="{0:F10}"  >                              
                            </telerik:GridNumericColumn>   


Thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Feb 2010, 05:52 AM
Hello Michael,

One suggestion is accessing the control in code behind and setting the decimal digits value there as shown below.

C#:
 
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            RadNumericTextBox textbox = (RadNumericTextBox)editItem["Reduction"].Controls[0]; 
            textbox.NumberFormat.AllowRounding = true
            textbox.NumberFormat.DecimalDigits = 8; 
        }  
    } 

-Shinu.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or