numeric型在C#中的合计出错(输入的字符串格式不正确)??
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();
}
}