I have a double variable assigned to a boundfield in a gridview. There will only ever be a max of 5 decimal places.

The boundfield is formatting the display to a scientific value. I'm assuming because it would default to a general format which gives the most compact of either fixed-point or scientific notation (https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring%28v=vs.110%29.aspx)

How can i format the number to show only as many decimal places as needed, up to 5. And do not show scientfic notation?

i.e. 0.00002 is currently showing as 2E-05, but I would like it to show as 0.00002. 0.002 should show as that, and not 0.00200. 1 should show that, and not 1.00000. etc.

So a format such as {0:N5} would not work. {0:N} defaults to 2 decimal places, and so would not work either.

Thanks for any help.

Related posts

Recent Viewed