Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ASP.Net gridview calculate with bind in templatefield

Posted on 2009-04-24
2
Medium Priority
?
1,075 Views
Last Modified: 2013-11-08
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")
<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>

Open in new window

0
Comment
Question by:NicoJuicy
2 Comments
 
LVL 8

Accepted Solution

by:
bedanand earned 2000 total points
ID: 24223386
Do
Eval("aantal") * Eval("verkoopPrijs")

instead of

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


Regards
Bedanand
http://www.dot4pro.com

0
 
LVL 7

Author Closing Comment

by:NicoJuicy
ID: 31574152
Excellent answer, works perfectly
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

580 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