本文介绍了System.InvalidCastException:无法将对象从DBNull强制转换为其他类型。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
任何人都可以帮我解决这个问题..

我不是要解决这个问题



这里是我的代码

十进制grdTotal = 0;

受保护 void GridView1_RowDataBound1( object sender,GridViewRowEventArgs e)
{


if (e.Row.RowType == DataControlRowType.DataRow)
{
decimal rowTotal = Convert.ToDecimal
(DataBinder.Eval(e.Row.DataItem, tsMonday));

grdTotal = grdTotal + rowTotal;

}

if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl =(Label)e.Row.FindControl( lblTotal);
lbl.Text = grdTotal.ToString( c);
}




}







十进制rowTotal = Convert.ToDecimal 



这一行收到错误..



请建议我..

谢谢你

解决方案

hican any one help me to solve this..
am not trying to solve this

here is my code
decimal grdTotal=0;

protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
    {


        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            decimal rowTotal = Convert.ToDecimal
                (DataBinder.Eval(e.Row.DataItem, "tsMonday"));

            grdTotal = grdTotal + rowTotal;

        }

        if (e.Row.RowType == DataControlRowType.Footer)
        {
            Label lbl = (Label)e.Row.FindControl("lblTotal");
            lbl.Text = grdTotal.ToString("c");
        }




    }




decimal rowTotal = Convert.ToDecimal


this line am getting error..

please suggest me..
thank you

解决方案


这篇关于System.InvalidCastException:无法将对象从DBNull强制转换为其他类型。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 01:15