Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:16:06+00:00 2026-05-26T22:16:06+00:00

I have a GridView with 2 BoundFields like this: <asp:BoundField DataField=UnitPrice HeaderText=Unit Price> </asp:BoundField>

  • 0

I have a GridView with 2 BoundFields like this:

<asp:BoundField DataField="UnitPrice" HeaderText="Unit Price">
        </asp:BoundField>

<asp:BoundField DataField="Quantity" HeaderText="Quantity">
        </asp:BoundField>

How do I add a “Total” field which is calculated by multiplying the other 2 fields to the GridView declaratively? These 2 existing fields are from an SQL database and I cannot add new fields to this database. In a way, I must create the Total field dynamically.

If this is not possible, how to do this programmatically?
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:16:06+00:00Added an answer on May 26, 2026 at 10:16 pm

    Easiest way would be to add a property to the underlying class:

    Decimal Total { get { return UnitPrice*Quantity; } }
    

    You can then reference the field Total in a BoundField

    If modifying the underlying class isn’t an option, try this:

    <asp:TemplateField>
       <ItemTemplate>
          <asp:Label runat="server" Text='<%# String.Format("{0:c}", ((Decimal)Eval("UnitPrice"))*((int)Eval("Quantity"))) %>' />
       </ItemTemplate>
    </asp:TemplateField>
    

    Note that you will want to make sure the casts for each Eval match your data structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView with three databound columns, like this: <Columns> <asp:BoundField HeaderText=Type DataField=Type
I have a GridView defined like this: <asp:GridView ID=myGridView ruant=server> <asp:BoundField DataField=myField /> <asp:CommandField
I have a GridView like this <asp:GridView ID=gv_FilesList runat=server AutoGenerateColumns=false onrowcommand=gv_FilesList_RowCommand> <Columns> <asp:BoundField DataField=f_Id
Here's what I have (working) : <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=false> <Columns> <asp:BoundField HeaderText=Id DataField=Id
i have followed GridView in my ASP.Net Page: http://s2.imgimg.de/uploads/14b706b38JPG.jpg It should look like this:
I have a GridView just like this: <asp:GridView ID=gvwStudents runat=server AutoGenerateColumns=False DataKeyNames=ID ShowHeader=False onrowdeleting=gvwStudents_RowDeleting>
I have a simple grid view like this : <asp:GridView ID=gv_userActivities runat=server AutoGenerateColumns=False> <Columns>
I have the following gridview: <asp:GridView ID=gdvReport runat=server AutoGenerateColumns=False DataSourceID=sdseport> <Columns> <asp:BoundField DataField=Phone HeaderText=Phone
I have a gridview with some boundfields and templatefields. My data are sales Unit-Price-Store,
I have a gridview like below: <asp:GridView DataKeyNames=TransactionID AllowSorting=True AllowPaging=TrueID=grvBrokerage runat=server AutoGenerateColumns=False CssClass=datatable Width=100%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.