I'm building an invoice page, and using a datagrid to display all the items in the order. Below the datagrid is a series of input boxes where the user enters tax, brokerage, duty, etc. I need to add these on the fly entered numbers to the calculated subtotal from the datagrid.
Is there a way to have the datagrid make this calculation and store it as a variable, or will I need to do a seperate database call to calculate the subtotal? I know the datagrid can be used to display a footer row with subtotals, but how would I use that value outside of the datagrid?
Example of what I'm looking for:
Part# | Quantity | Unit Price | Amount
Part# | Quantity | Unit Price | Amount
Part# | Quantity | Unit Price | Amount
Part# | Quantity | Unit Price | Amount
--------------------------------------
Subtotal |___________| <------- subtotal of the "Amount" field from datagrid
Tax |___________|
Brokerage |____________|
Duty |___________|
Total _____________ <---- Calculated on the fly
Is there a way to have the datagrid make this calculation and store it as a variable, or will I need to do a seperate database call to calculate the subtotal? I know the datagrid can be used to display a footer row with subtotals, but how would I use that value outside of the datagrid?
Code:
<asp:datagrid id="ItemGrid" runat="server" showheader="true"
AutogenerateColumns="False" DataKeyField="ID">
<Columns>
<asp:BoundColumn DataField="PartNumber" runat="server" />
<asp:BoundColumn DataField="Quantity" runat="server" />
<asp:BoundColumn DataField="UnitSellPrice" runat="server" />
<asp:BoundColumn DataField="ItemTotal" runat="server" />
</Columns>
</asp:datagrid>
Example of what I'm looking for:
Part# | Quantity | Unit Price | Amount
Part# | Quantity | Unit Price | Amount
Part# | Quantity | Unit Price | Amount
Part# | Quantity | Unit Price | Amount
--------------------------------------
Subtotal |___________| <------- subtotal of the "Amount" field from datagrid
Tax |___________|
Brokerage |____________|
Duty |___________|
Total _____________ <---- Calculated on the fly