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

Rounding in Grid

1 Answer 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tomáš
Top achievements
Rank 1
Tomáš asked on 09 Mar 2009, 02:50 PM
Hello!

It's possible to round number directly in RadGrid? I have grid and I dynamically create its structure. I get from my database numbers like 3.123456789 , but i need to show just 3.12

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Mar 2009, 05:30 AM
Hi Tomas,

Try setting the DataFormatString for the Grid column as shown below and see whether it is working.

ASPX:
 
<telerik:GridBoundColumn UniqueName="UnitPrice"   
DataFormatString="{0:N2}"    HeaderText="UnitPrice" DataField="UnitPrice" ></telerik:GridBoundColumn> 


If you are creating the Grid Column dynamically you may try the following approach.

CS:
GridBoundColumn boundCol = new GridBoundColumn(); 
            RadGrid1.MasterTableView.Columns.Add(boundCol); 
            boundCol.DataField = "UnitPrice"
            boundCol.HeaderText = "UnitPrice"
            boundCol.UniqueName = "UnitPrice"
            boundCol.DataFormatString = "{0:N2}"



Thanks
Shinu
Tags
Grid
Asked by
Tomáš
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or