Gridview column formatting


E

et

I have tried everything to display a bound column in a gridview to 2
decimals only. The column is a price, and when I run the query in sql, he
value displays as 10.00. Yet in the grid view it displays as 10.0000. I
have tried various settings in the dataformatstring, and it seems to ignore
everything I put there; I've tried: {0}, {0:F2}, {0:d}, {0:c}, among
others. What am I doing wrong?
 
Ad

Advertisements

A

Alvin Bruney [MVP]

hook into the itemdatabound event handler and set the cell the way you want
it. consider
e.item.cells[colInQuestion].Text = "#.##";//picture format
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top