Hello there, It means that you are trying to dereference a value which is a null reference. Kindly check you GridView1_RowUpdating event where you are finding controls from within the EditItemTemplate and performing a type cast to read the values from those controls.
The exception stack trace may help you find the problem on which line you are getting the error.
The Error is only stating you what is the cause. It saying that you might have not initialized your connectionstring property of your Connection object.
Eg.
SqlConnection con=new SqlConnection();
Over here I created an instance of my SqlConnection class but not initialized the ConnectionString Property of the SqlConnection Class. There are 2 ways to do it.
Way 1:
SqlConnection con=new SqlConnection("Specify your connection string over here");
Way 2:
SqlConnection con=new SqlConnection(); con.ConnectionString="Specify your Connection string over here";
solved that one now am getting this one.. Connection property has not been initialized. and this my code::
Line 104: Line 105: SqlCommand cmd = new SqlCommand("update Employee_Details set NAME='" + NAME + "',ADDRESS='" + ADDRESS + "', designation='" + DESIGNATION + "' where ID=" + ID); Line 106: int result = cmd.ExecuteNonQuery(); Line 107: con.Close(); Line 108: if (result == 1)
Vishal GilbilePosted Mar 11, 2013, 3:10 AM
It means that you are trying to dereference a value which is a null reference. Kindly check you GridView1_RowUpdating event where you are finding controls from within the EditItemTemplate and performing a type cast to read the values from those controls.
The exception stack trace may help you find the problem on which line you are getting the error.
With Regards,
Vishal Gilbile.
Vishal GilbilePosted Mar 11, 2013, 5:10 AM
Eg.
SqlConnection con=new SqlConnection();
Over here I created an instance of my SqlConnection class but not initialized the ConnectionString Property of the SqlConnection Class.
There are 2 ways to do it.
Way 1:
SqlConnection con=new SqlConnection("Specify your connection string over here");
Way 2:
SqlConnection con=new SqlConnection();
con.ConnectionString="Specify your Connection string over here";
Hope that solves your problem.
With Regards,
Vishal Gilbile.
AbhiPriya M VPosted Mar 11, 2013, 3:50 AM
solved that one now am getting this one..
Connection property has not been initialized.
and this my code::
Line 104: Line 105: SqlCommand cmd = new SqlCommand("update Employee_Details set NAME='" + NAME + "',ADDRESS='" + ADDRESS + "', designation='" + DESIGNATION + "' where ID=" + ID); Line 106: int result = cmd.ExecuteNonQuery(); Line 107: con.Close(); Line 108: if (result == 1)