System.InvalidCastException:无法将对象从DBNull强制转换为其他类型。 [英] System.InvalidCastException: Object cannot be cast from DBNull to other types.?
问题描述
hi
任何人都可以帮我解决这个问题..
我不是要解决这个问题
这里是我的代码
十进制grdTotal = 0;
<前lang =cs> 受保护 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
这一行收到错误..
请建议我..
谢谢你请参考这个并尝试写格式就像他们说的那样 -
http:// forums。 asp.net/t/1162142.aspx/1 [ ^ ]
hi
can 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
Refer this and try to write format like they said-
http://forums.asp.net/t/1162142.aspx/1[^]
这篇关于System.InvalidCastException:无法将对象从DBNull强制转换为其他类型。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!