When developing a .Net web application, if a run time error is generated, it shows some “extra” debug information that I can’t find in the Exception class.
It shows a “Source Error” section which shows a code excerpt with line numbers showing exactly where the error was generated and it shows the “Source File”, the actual page that threw the exception.
Can this information be gathered and logged programatically?
FYI I’m not using an error logging framework, the app simply captures errors in the Global.asax.cs file and writes the contents of the exception to a DB table. Maybe this is where I’m going wrong. Let me know if i’ll need to adopt a framework to support quality logging.

You should take a look at the ELMAH project which will allow you to automatically capture and log all unhandled exceptions including recording the yellow screen of death.
For each error, as well as recording the YSOD, and stack trace it will also record the server variables too so you can see information such as http referrer, page requested, etc.
It can record exceptions in a various databases or xml files, and send you an email as they are logged. It can be integrated into a running .Net web application without changing a line of code, just adding entries to web.config
You can also log entries in the log programatically for when you want to catch the exception but still record it.
Full details are on the ELMAH website, and a getting started guide on the Elmah.io site.