Click here to Skip to main content
11,710,423 members (86,804 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET
hello all,

I have a grid view where i am binding the value of price and tax and i want to show them upto two digits after decimal..

.aspx code:-

<asp:GridView runat="server" AllowPaging="True" AlternatingRowStyle-CssClass="alt"
        CellPadding="4" CellSpacing="2" CssClass="mGrid"
        EmptyDataText="There is no Item in your Cart" ForeColor="Black"
                                GridLines="None" ID="Grid1"
        AutoGenerateColumns="False" DataKeyNames="pid"
        onrowdeleting="Grid1_RowDeleting" PagerStyle-CssClass="pgr" ShowFooter="True"
                                Width="100%" onrowediting="Grid1_RowEditing"
                                <RowStyle BackColor="White" />
<asp:TemplateField HeaderText="Product ID">
<asp:Label runat="server" ID="lblpid" Text='<%#Eval("PID") %>'></asp:Label>
<asp:TemplateField HeaderText="Name">
<asp:Label runat="server" ID="lblname" Text='<%#Eval("Name") %>'></asp:Label>
<asp:TemplateField HeaderText="Quantity">
<asp:Label runat="server" ID="lblquantity" Text='<%#Eval("Quantity") %>'></asp:Label>
&nbsp; &nbsp;
<asp:LinkButton runat="server" ID="linkedit" CommandName="Edit" Text="Edit" Font-Underline="false"></asp:LinkButton>
<asp:TextBox runat="server" ID="txtquantity" Text='<%#Eval("Quantity") %>'></asp:TextBox>
<asp:LinkButton runat="server" ID="linkupdate" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton runat="server" ID="linkcancel" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
<asp:TemplateField HeaderText="Price">
<asp:Label runat="server" ID="lblprice" Text='<%#Eval("UnitPrice") %>'></asp:Label>
<asp:TemplateField HeaderText="Tax">
<asp:Label runat="server" ID="lbltax" Text='<%#Eval("Tax") %>'></asp:Label>
<asp:TemplateField HeaderText="Total">
<asp:Label runat="server" ID="lkbltotalprice" Text='<%# Eval("TotalPrice") %>'></asp:Label>
<asp:LinkButton runat="server" ID="linkdlt" CommandName="Delete"><asp:Image runat="server" ImageUrl="~/WebSiteImages/delete_button.gif" /></asp:LinkButton>
<FooterStyle BackColor="#CCCCCC" />
                                <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
                                <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                                <AlternatingRowStyle CssClass="alt" />

kindly suggest me any solution to format it in eval function...
Posted 20-May-12 19:35pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


<% # Eval("Amount","{0:#0.00}") %>
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

hi dear

use displayformat = "{0}:2D" in Gridview colum

abhishekagrwl25 at 22-May-12 3:09am
but how to set displayformat in GridView column.??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 549
1 OriginalGriff 270
2 Peter Leow 134
3 Abhinav S 130
4 Richard MacCutchan 80
0 Abhinav S 60
1 Member 4653839 40
2 barneyman 35
3 Sergey Alexandrovich Kryukov 35
4 Member 11793820 35

Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 21 May 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100