When we try passing the Query Parameter Name as ID to the .aspx Page (which itself is the record in the document library) Sharepoint loses track of what ID is used for. Sharepoint no longer knows if ID is the document in the document library or the ID of the listItem which we need to update using this .aspx page. This problem happens because Sharepoint has its own variable named ID which it uses to identify documents/pages on the server. Our solution should not be using a variable named ID.
Change the query string parameter from ID to CustomID. Then change the details page from QueryString(ID) to QueryString(CustomID). Once this is done the page will display with no errors.