0
votes

Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

    Line 31:             SqlCommand cmd = new SqlCommand("GetContact");
    Line 32:             cmd.CommandType =  CommandType.StoredProcedure;
    Line 33:             cmd.Parameters.AddWithValue("@fname", ViewState["fname"].ToString());
    Line 34:             cmd.Connection = con;
    Line 35:             sda.SelectCommand = cmd;
1

1 Answers

0
votes

Find the line that is throwing the exception from the exception details - In this line, check that every variable you are using has been correctly initialized.

ViewState["fname"].ToString()  

viewstate having value or it's null