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

Formatting Numeric Columns in a GridDataBoundGrid

I have a simple question but I haven''t been able to find the answer or a sample in the documentation. I would like to format an entire floating point column of data coming from a DataSet in a GridDataBoundGrid. For instance, I would like to round the numbers for an entire column to 2 decimals and put commas in for every third digit left of the decimal point ( ie 5,232,233.54 ). Can someone point me in the right direction or show an example of how to do this? Thanks, Dan

2 Replies

JF Jim Frapper December 1, 2003 04:34 PM UTC

Hey Dan, You can just change the cell type for the columns in your databound grid. For example... this.grdAppointments.Binder.InternalColumns[1].StyleInfo.CellType = "Static"; Search in the ".NET style documentation" for CellType. This will give you the list you are looking for. For your specific cell type, you could use NumericUpDown, Currency, MaskedEdit, or even Static(if you format you value before you set it). Cheers, JF


AD Administrator Syncfusion Team December 1, 2003 04:49 PM UTC

In addition to setting the CellType property, this.grdAppointments.Binder.InternalColumns[1].StyleInfo.CellType as Jim mentioned, you can also set the Format property and the CellValueTyle property. this.grdAppointments.Binder.InternalColumns[1].StyleInfo.Format = "#.####"; //or "F4" or ??? this.grdAppointments.Binder.InternalColumns[1].StyleInfo.CellValueType = typeof(double)

Loader.
Live Chat Icon For mobile
Up arrow icon