Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > format Boundcolumn as Percentage

Reply
Thread Tools

format Boundcolumn as Percentage

 
 
RobbRoss
Guest
Posts: n/a
 
      06-17-2004
I have a datagrid with Boundcolumns. I have a number in the db that represents a percentage. I want the datagrid column to output the percentage and not the number. For example instead of 0.82 I want 82%.
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      06-17-2004
You can use a custom format with "p".

<Columns>
<asp:BoundColumn DataField="Percentvalue" ReadOnly="True"
HeaderText="Percentvalue" DataFormatString="{0}"></asp:BoundColumn>
</Columns>

See also here:

http://www.datawebcontrols.com/faqs/...ericData.shtml

Ken
Microsoft MVP [ASP.NET]

"RobbRoss" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a datagrid with Boundcolumns. I have a number in the db that
>represents a percentage. I want the datagrid column to output the
>percentage and not the number. For example instead of 0.82 I want 82%.


 
Reply With Quote
 
 
 
 
Jos
Guest
Posts: n/a
 
      06-17-2004

"RobbRoss" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a datagrid with Boundcolumns. I have a number in the db that

represents a percentage. I want the datagrid column to output the
percentage and not the number. For example instead of 0.82 I want 82%.

Set the DataFormatString property for the BoundColumn to {0:##.00%}
like this:
<asp:BoundColumn DataField="MyNumberField" DataFormatString="{0:##.00%}">

More formatting options here:
http://msdn.microsoft.com/library/en...matstrings.asp

Jos


 
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
Boundcolumn or TemplateField when to use Boundcolumn and when TemplateField ???? mesut ASP .Net 0 06-29-2007 10:17 AM
Format Double Values using BoundColumn.DataFormatString Prasad Dannani ASP .Net Datagrid Control 1 06-27-2005 12:07 PM
DataGrid ButtonColumn/BoundColumn problem John ASP .Net 3 11-03-2003 02:20 PM
Re: DataGrid - problem with calling handler for BoundColumn Newton ASP .Net 1 07-27-2003 09:47 AM
convert tablecell to boundcolumn May ASP .Net 0 06-30-2003 07:43 PM



Advertisments