HighTechTalks DotNet Forums  

Gridview column formatting

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Gridview column formatting in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
et
 
Posts: n/a

Default Gridview column formatting - 01-15-2007 , 03:11 PM






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?



Reply With Quote
  #2  
Old   
Alvin Bruney [MVP]
 
Posts: n/a

Default Re: Gridview column formatting - 01-16-2007 , 11:13 PM






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

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc

"et" <eagletender2001 (AT) yahoo (DOT) com> wrote

Quote:
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?




Reply With Quote
  #3  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: Gridview column formatting - 01-18-2007 , 11:10 AM



Set HtmlEncode = false for the column.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"et" <eagletender2001 (AT) yahoo (DOT) com> wrote

Quote:
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?




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.