ASP.Net gridview calculate with bind in templatefield

Posted on 2009-04-24
Last Modified: 2013-11-08
How come in 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")
<asp:GridView ID="gvWinkelwagentjeKoop" runat="server" AutoGenerateColumns="False" DataKeyNames="DVDId,soortAankoop">


                                        <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">


                                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("aantal") * Bind("verkoopPrijs") %>'></asp:TextBox>



                                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("aantal") * Bind("verkoopPrijs") %>'></asp:Label>



                                            <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" 





Open in new window

Question by:NicoJuicy
    LVL 8

    Accepted Solution

    Eval("aantal") * Eval("verkoopPrijs")

    instead of

    Bind("aantal") * Bind("verkoopPrijs")


    LVL 7

    Author Closing Comment

    Excellent answer, works perfectly

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now