Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format datagrid item as percent

Status
Not open for further replies.

sladd

IS-IT--Management
Mar 7, 2001
44
US
I am trying to display a cell from my database which is formatted as a percent and restricted to 2 decimals. This works fine but the number is displayed with its full precision and not as a percent. I've been searching for how to format the item with no luck. I assume that I do this in my datagrid boundcolumn reference listed below. Any help is greatly appreciated.

Thanks,
Steve

<asp:BoundColumn DataField=&quot;Trend&quot; ReadOnly=&quot;True&quot; HeaderText=&quot;Trend&quot;></asp:BoundColumn>
 
If I understand you correctly you have a value which is in your DataSet as .#### and you want it to come out ##.##.

I would recommend that you bring that data into the DataSet after you have divided it by 100 to get a whole number. Make the /100 part of your query. Then you can format it to have no more than 2 decimal places by using DataFormatString=&quot;{0:N2}&quot;. Of if there are only 2 numbers at all &quot;{0:N0}&quot;

Hope that helps.

If you are bringing your DataSet in with a SQL stored proc the /100 would look like:

SELECT
MyPercent = (Field / 100)
FROM
MyTable

Eva
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top