zoukankan      html  css  js  c++  java
  • 一个购物车中修改商品数量的实列


    //在这个实列中,只要你修改某件商品的数量,就会触发一个TextChanged事件,在这个事件中它会遍历datalist中的每一行,然后得到每一行中的单价,和数量,最后把算出的结果附给总价,每行都这么做。就达到更新的目的了。。
    protected void txtCount_TextChanged(object sender, EventArgs e)
        {
            double theTotal = 0;
            for (int i = 0; i < this.DataList1.Items.Count; i++)
            {
                string value = ((Label)this.DataList1.Items[i].FindControl("price")).Text;
                double  price = Convert.ToDouble(value);
                int count = Convert.ToInt32(((TextBox)this.DataList1.Items[i].FindControl("txtCount")).Text);
                ((Label)this.DataList1.Items[i].FindControl("total")).Text = Convert.ToString(price * count);
                theTotal = theTotal + price * count;
            }
            this.totalPrice.Text = theTotal.ToString();
        }
  • 相关阅读:
    jenkins部署前端node项目实例
    阿里云云盘扩容数据盘_Linux
    输入子系统
    触摸屏设备驱动程序
    LCD设备驱动程序
    IIC设备驱动程序
    看门狗驱动程序
    RTC实时时钟驱动
    网络设备驱动程序数据结构
    Linux 设备驱动模型
  • 原文地址:https://www.cnblogs.com/wantingqiang/p/1217048.html
Copyright © 2011-2022 走看看