Format GridView Colums to 1 decimal place

HI I have the following gridview how can I format the data to 1decimal place??

Is there a property as I can't seem to see anything??


 <asp:GridView ID="gvSurveyResults" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource11"
                CellPadding="4" ForeColor="#333333" GridLines="None" OnLoad="gvSurveyResults_Load" Font-Names="Arial, Small Caps"  Font-Size="Larger">
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Font-Names="Arial, Small Caps"
                <RowStyle BackColor="#EFF3FB" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#2461BF" />
                <AlternatingRowStyle BackColor="White" />
                    <asp:BoundField DataField="Text" HeaderText="Question" SortExpression="Text" />
                    <asp:BoundField DataField="AvgResponseValue" HeaderText="Avg Question Value For All Responses" ReadOnly="True"
                        SortExpression="AvgResponseValue" />
            <asp:ObjectDataSource ID="ObjectDataSource11" runat="server" OldValuesParameterFormatString="original_{0}"
                SelectMethod="GetData" TypeName="SurveyDataSetTableAdapters.GetAvgResponseValueTableAdapter">
                    <asp:SessionParameter Name="surveyId" SessionField="SurveyId" Type="Int32" />
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"></asp:ObjectDataSource>
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Add the Format String for your BoundField to use {0:P1} for one decimal place or you can also handle this in your SQL code.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I also had to do the same thing myself and I had to set the field in my database to use the decimal type and I changed the precision to 6 and scale to 1. Then I used the following SQL statement below.

select field1, field2, field3/100 as decimalfield
from tablename
bailey1200Author Commented:
In here: <asp:BoundField FormatString="" >

I dont seem to have a bound format string  property avaliable to me...
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

bailey1200Author Commented:
Hi I have found
DataFormatString="{0:P1} " but this doesn't do anything! Any ideas?
>> DataFormatString="{0:P1} " but this doesn't do anything! Any ideas?

This is correct, you can also try 0:P2.

Can you post example data that is stored in your decimal field?? That would help out along with posting your code.
bailey1200Author Commented:
Hi thanks i have that working now but it is changing the figures to pecentages and I need it to be 2decimal places!
Alfred A.Commented:
You can try something like this,

<asp:boundfield headertext = "Price"
   datafield = "Price"
   dataformatstring = "{0:F1}"
   itemstyle-horizontalalign = "right" />
Alfred A.Commented:
For two decimal places,

dataformatstring = "{0:F2}"
Alfred A.Commented:
Actually, this should be find for two decimal places.

dataformatstring = "{0:F}"
Try the following below and let me know how it works.

{0:D} or {0:D2}
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.