指定演员表无效, [英] Specified cast is not valid,

查看:92
本文介绍了指定演员表无效,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

double total = 0;

            foreach (DataGridViewRow row in gvpurchase.Rows)
            {
                if (!row.IsNewRow && row.Cells["paid"].Value != null)
                {
                    total += (double)row.Cells["paid"].Value;

                    //Convert.ToInt32(["paid"]);
                }
            }

            lbltotal.Text = total.ToString("N2");
        }




    }





< b>我尝试了什么:



我在Windows应用程序的标签中获得了网格视图总金额,但是我收到错误Specified Cast无效,如何解决这个错误。请给我一些想法。



What I have tried:

I get grid view sum amount in label for windows application, but i got a error Specified Cast is not valid, how to solve this error. Any one please give me ideas.

推荐答案

这行代码就是问题:

This line of code is the issue:
total += (double)row.Cells["paid"].Value;





错误说你无法转换为row.Cells [paid]中的任何内容。值。也许这是一片空白。无论如何,调试代码,你会看到。



The error says you cannot convert to double whatever is in row.Cells["paid"].Value. Perhaps it is a blank. Regardless, debug the code and you'll see.


这篇关于指定演员表无效,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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