Troubleshooting Exceptions: System.NullReferenceException
<pre><pre> protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string val1 = e.Row.Cells[16].Text; //Gets the value in Column 1 string val2 = e.Row.Cells[15].Text; //Gets the value in Column 2 string val3 = e.Row.Cells[14].Text; //Gets the value in Column 3 string val4 = e.Row.Cells[13].Text; //Gets the value in Column 4 Label lblTotal = (Label)e.Row.Cells[12].FindControl("Label1"); // float _val1, _val2, _val3, _val4; float.TryParse(val1, out _val1); float.TryParse(val2, out _val2); float.TryParse(val3, out _val3); float.TryParse(val4, out _val4); float sum = _val1 + _val2 + _val3 + _val4; lblTotal.Text += sum.ToString(); -------------------> the error is here }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)