Very new in the C# world so give me a break here. I have created two
web forms, one passes information to the other and brings up the data
based on the passed field. When I do the updateRow I get the object
recrence not set to an instance of an object. If I rem out the error
message on the update it goes through and acts as though it updates
but does not. Here is the updateRow statements:
private void updateRow(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
try
{
ErrorMessage.Text = "";
SqlCommand updCommand = new SqlCommand();
updCommand.Connection = sqlConnection1;
updCommand.CommandText = "UPDATE HSE Compliance SET Date = '"
+ ((TextBox)e.Item.Cells[2].Controls[0]).Text + "', Description =
'" + ((TextBox)e.Item.Cells[3].Controls[0]).Text + "', Manager = '" +
((TextBox)e.Item.Cells[4].Controls[0]).Text + "', Risk-ranking = '" +
((TextBox)e.Item.Cells[5].Controls[0]).Text + "', Status = '" +
((TextBox)e.Item.Cells[6].Controls[0]).Text + "'"
+ "WHERE Ref_No = '" + ((TextBox)e.Item.Cells[1].Controls[0]).Text
+ "'";
Label2.Text = "Updating Ref No " +
((TextBox)e.Item.Cells[1].Controls[0]).Text;
updCommand.CommandType = CommandType.Text;
sqlConnection1.Open();
updCommand.ExecuteNonQuery();
sqlDataAdapter1.Fill(dataSet1);
Cache["hse_inputform"] = dataSet1;
DataGrid1.EditItemIndex = -1;
bindGrid();
sqlConnection1.Close();
}
catch(Exception ex)
{
ErrorMessage.Text = ex.Message;
}
please help