NicoJuicy
asked on
ASP.Net gridview calculate with bind in templatefield
How come in asp.net that a calculated row doesn't multiply?
The code is given below, but this is not working:
Bind("aantal") * Bind("verkoopPrijs")
I want aantal (= ammount) x verkoopPrijs (= SalesPrice), but it only displays the salesPrice (verkoopPrijs).
Also, i want to know how a gridview total is set in a footertemplate (by adding the totals of 1 column, the column here is named "Bedrag")
The code is given below, but this is not working:
Bind("aantal") * Bind("verkoopPrijs")
I want aantal (= ammount) x verkoopPrijs (= SalesPrice), but it only displays the salesPrice (verkoopPrijs).
Also, i want to know how a gridview total is set in a footertemplate (by adding the totals of 1 column, the column here is named "Bedrag")
<asp:GridView ID="gvWinkelwagentjeKoop" runat="server" AutoGenerateColumns="False" DataKeyNames="DVDId,soortAankoop">
<Columns>
<asp:BoundField DataField="naam" HeaderText="Categorie" ReadOnly="true" showHeader="false" />
<asp:BoundField DataField="Titel" HeaderText="Titel" ReadOnly="true" showHeader="false" />
<asp:BoundField DataField="verkoopPrijs" HeaderText="Prijs per eenheid" ReadOnly="true" showHeader="false" visible="true"/>
<asp:BoundField DataField="aantal" HeaderText="Aantal" ReadOnly="false" showHeader="false" />
<asp:TemplateField HeaderText="Bedrag" ShowHeader="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("aantal") * Bind("verkoopPrijs") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("aantal") * Bind("verkoopPrijs") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DVDId" HeaderText="DVD Id" ReadOnly="true" showHeader="false" visible="false"/>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
CancelText="Annuleer" DeleteText="Verwijder" EditText="Aanpassen"
InsertText="Toevoegen" NewText="Nieuw" SelectText="Selecteer"
CausesValidation="False"/>
</Columns>
</asp:GridView></p><p>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER