简体   繁体   中英

How to multiply two columns and display that in another column in a gridview using vb.net

Here is the gridview part. Somebody please help me to find the answer. I want to multiply Count and Price and display the sum in Amount .

<asp:TemplateField HeaderText="Price">
    <ItemTemplate>
        <asp:Label ID="lblCardPrice" runat="server" Text='<%# Bind("Price")%>'></asp:Label>
    </ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Count" >
    <ItemTemplate>
        <asp:Label ID="lblCount" runat="server" Text='<%# Bind("Count")%>'></asp:Label>                                        
    </ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Amount">
    <ItemTemplate>
        <asp:Label ID="lblAmount" runat="server" Text='<%# Eval("(Amount)")%>'></asp:Label>                                        
    </ItemTemplate>
</asp:TemplateField>

try this:

<asp:TemplateField HeaderText="Amount" >
<ItemTemplate >

<asp:Label ID="lblAmount" runat="server" Text='<%#  Convert.ToInt32(Eval("Count"))*Convert.ToInt32(Eval("Price"))%>'></asp:Label>                                        
</ItemTemplate>
</asp:TemplateField>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM