如何将购物车总价值绑定到我的购物车框中 [英] how to bind shopping cart total value in my cart box

查看:59
本文介绍了如何将购物车总价值绑定到我的购物车框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将购物车总价值绑定到我的购物车框中

how to bind shopping cart total value in my cart box

推荐答案

假设您具有用于显示购物车项目和价格的网格视图,则可以使用下面的代码绑定购物车总计:

Assuming you have a grid view for displaying the cart items and prices, then you can use the below code to bind shopping cart total:

decimal grdTotal = 0;

protected void Page_Load(object sender, EventArgs e){}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
  if (e.Row.RowType == DataControlRowType.DataRow)
  {
    decimal rowTotal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "price"));
    grdTotal = grdTotal + rowTotal;
  }
  lbl.Text = grdTotal.ToString("c");
}


这篇关于如何将购物车总价值绑定到我的购物车框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆