嗨,在您的 gridview 中执行此操作
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:Label ID="lblAmount" runat="server"
Text='<%# Eval("Amount","0:N2}").ToString %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotal" runat="server"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
现在像公开一样声明
Private grdTotal As Decimal = 0
在事件 RowDataBound 从您的 gridview 之后
If e.Row.RowType = DataControlRowType.DataRow Then
Dim rowTotal As Decimal =
Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Amount"))
grdTotal = grdTotal + rowTotal
End If
If e.Row.RowType = DataControlRowType.Footer Then
Dim lbl As Label = DirectCast(e.Row.FindControl("lblTotal"), Label)
lbl.Text = grdTotal.ToString("N2")
End If