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.
Easiest way would be to add a property to the underlying class:
You can then reference the field
Totalin aBoundFieldIf modifying the underlying class isn’t an option, try this:
Note that you will want to make sure the casts for each
Evalmatch your data structure.