Gridview中的折扣计算

时间:2011-12-08 06:17:50

标签: c# asp.net .net

在我的gridview中,我有卖价,数量,折扣,净额。       用户输入数量和折扣,结果应该显示在我正在尝试使用此代码的netamount列中,它不会出现:

        foreach (GridViewRow row in GridView1.Rows)
        {
            Label subtot;
            TextBox txtSerAmt = (TextBox)row.FindControl("TxtServiceAmount");
            TextBox txtQuantity = (TextBox)row.FindControl("txtQuantity");
            TextBox txtdsAmount = (TextBox)row.FindControl("txtdsAmount");
            TextBox TxtNetAmt = (TextBox)row.FindControl("TxtNetAmt");

            if (txtSerAmt != null && txtQuantity != null && txtdsAmount != null)
            {
               TxtNetAmt.Text = (((
               Convert.ToDouble(txtSerAmt.Text) * Convert.ToDouble(txtQuantity.Text))) * Convert.ToDouble(txtdsAmount.Text)/100).ToString();
            }
        }

这段代码我写过textchanged事件帮我解决问题..........

1 个答案:

答案 0 :(得分:0)

TextBox控件是否在样本中命名?再看一下,因为其中一些在开头有一个大写字母而有些没有。也许你混淆了名字。 C#区分大小写。