本文介绍了如何在GridView中减去两列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何减去列成本,保险成本并将结果存储在每行的总计?!



myCode:

how to minus column Cost,insuranceCost and store the result in a column Total for each row?!

myCode:

ServiceInsuranceList = new System.Data.DataTable();




private void BtnAdd_Click(object sender, EventArgs e)
       {

             GrdServiceInsurance.DataSource = ServiceInsuranceList;
                for (int i = 0; i < GrdServiceInsurance.Rows.Count; ++i)
                {
 GrdServiceInsurance.Rows[i].Cells["Total"].Value =(Convert.ToInt32( GrdServiceInsurance.Rows[i].Cells["Cost"].Value.ToString())) -(Convert.ToInt32( GrdServiceInsurance.Rows[i].Cells["InsuranceCost"].Value.ToString())) 
                }

       }





但它不起作用......

错误对象引用不是设置为对象的实例。



But it does not work...
error "Object reference not set to an instance of an object."

推荐答案




这篇关于如何在GridView中减去两列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 14:02