You must Sign In to post a response.
  • Category: ASP.NET

    Object reference not set to an instance of object

    Add button code as follows

    Sql = "select cpm_pkg_id from CO_PACKAGE_MASTER where cpm_pkg_name = '" + txtpkgdesc.Text.ToString().Trim() + "' ";
    dt1 = SCon.ReadSql_DT(Sql);

    Sql ="Insert into CO_PACKAGE_DETAIL values('" + dt1.Rows[0]["cpm_pkg_id"].ToString() + "','" + gvmajormaster.selectedrow(1].tostring.trim() + "','" + gvmajormaster.selectedrows[2].tostring().trim() + "')";

    lblErr.Text = "Package details inserted successfully";

    In gridview as follows
    Select Major Code Minor Code

    i want to insert the above gridview row values PSTF (Major code) and AFF(Minor Code) into co_package detail.

    i tried the below code but shows error as follows
    Object reference not set to an instance of an object.
  • #762431
    Hi rao,

    As per error details, if you are trying to assign null value to some object in that scenario you may got this type of error. I request you to please debug your code and see in which line you got that error, and check the right hand side value of the same.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • Sign In to post your comments