numeric型在C#中的合计出错(输入的字符串格式不正确)??

kkk444dsfsa 2010-11-09 01:01:40
private int jshj = 0; numeric(19,0)
private decimal tjhj = 0; numeric(19,2)
private decimal zlhj = 0; numeric(19,2)

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//自动编号
if (e.Row.RowIndex != -1)
{
int id = e.Row.RowIndex + 1;
e.Row.Cells[0].Text = id.ToString();
}
//统计行
if (e.Row.RowIndex >= 0)
{
jshj += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "hwzjs")); //这行可以
tjhj += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,"hwztj")); //这行和下行都是输入字符串格式出错
zlhj += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "hwzzl"));
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[6].Text = "合计";
e.Row.Cells[7].Text = jshj.ToString();
e.Row.Cells[8].Text = tjhj.ToString();
e.Row.Cells[9].Text = zlhj.ToString();
}
}
...全文
96 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧