Saranya R Saranya R - 7 months ago 74
Vb.net Question

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>

Answer

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>