0

Is there some way I can use a data format string in a bound field which appends % to my value ?

Example :

For rupee we can do this :

  <asp:BoundField DataField="PassPercent" ItemStyle-Width="7%" HeaderText="Pass Percent" DataFormatString="{0:c}"

I tried using a template field too but that didn't work :

<asp:TemplateField HeaderText="Pass Percent" ItemStyle-Width="5%" >
                        <ItemTemplate>
                            <asp:Label runat="server" DataValueField="PassPercent"  DataTextField="PassPercent" />
                            <asp:Label Text="%" runat="server" />
                        </ItemTemplate>
                 </asp:TemplateField>
1
  • DataFormatString="{0}%" ...? Commented Feb 27, 2015 at 12:22

1 Answer 1

1

Try this:-

DataFormatString="{0:p}"

But, please note percentages are stored as decimals in this case so you need to adjust your values accordingly. Check the formatting's here on MSDN.

Or you can simply hard-code it:-

DataFormatString="{0}%"
Sign up to request clarification or add additional context in comments.

1 Comment

Can't delete ur comments :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.