Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Gridview column formatting

Reply
Thread Tools

Gridview column formatting

 
 
et
Guest
Posts: n/a
 
      01-15-2007
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
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      01-17-2007
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" <> wrote in message
news:...
>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
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-18-2007
Set HtmlEncode = false for the column.

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


"et" <> wrote in message
news:...
>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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting gridview column: mm/dd/yy Bobby Edward ASP .Net 3 11-15-2008 12:00 AM
gridview column values to another page via gridview hyperlink column Keith G Hicks ASP .Net 3 02-18-2008 06:17 AM
Gridview Formatting Issue : Bound Column Just Me ASP .Net 1 10-30-2007 09:38 AM
DataFormatString in GridView has no affect on column formatting pgonzo@improvementpath.com ASP .Net 2 01-18-2007 07:27 AM
How to hide a GridView column when the column's Visible property does not support databinding? Keithb ASP .Net 2 10-27-2006 05:02 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57