如何将两列相乘并使用vb.net在gridview的另一列中显示该列

时间:2014-11-26 05:36:49

标签: asp.net vb.net gridview

这是gridview部分。有人请帮我找到答案。我希望将CountPrice相乘,并在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>

1 个答案:

答案 0 :(得分:0)

试试这个:

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