We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Removing trailing zeros in DataBoundGrid

Hi, I am using DataBoundGrid I have a decimal column. How do I remove trailing Zeros from the decimal number when I show it in all my grids? FYI, run CurrencyCells sample and set one of the CellType to "TextBox" and CellValueType to decimal. If you enter "53.89400", it converts the value to "53.894". How can I get the same behavior in a databound grid? thanks, - Reddy

2 Replies

AD Administrator Syncfusion Team January 22, 2004 09:26 PM UTC

Try setting: GridStyleInfo style = this.gridDataBoundGrid1.Binder.InternalColumns[2].StyleInfo; style.CellValueType = typeof(double); style.Format = "0.000";

AD Administrator Syncfusion Team January 22, 2004 09:29 PM UTC

If you do not want to always have 3 decimal places, you can use the # formatting character instead of the 0. style.Format = "0.###"; 1.200000 is shown as 1.2 1.1234567 is shown as 1.123

Live Chat Icon For mobile
Up arrow icon