Server Error in '/' Application.

Conversion from type 'DBNull' to type 'String' is not valid.

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.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.

Source Error:


Line 38: 
Line 39:         If Not IsDBNull(FormView1.DataItem("Related3")) Then
Line 40:             Me.lblProd3.Text = FormView1.DataItem("Rel3")
Line 41:             Me.Rel3.Text = FormView1.DataItem("Rel3")
Line 42:             Me.Rel3.NavigateUrl = "~/productdetail.aspx?prodid=" & Convert.ToString(FormView1.DataItem("Related3")) & "&pid="

Source File: D:\Websites\Maths Star\Elevenplusmathv2\productdetail.aspx.vb    Line: 40

Stack Trace:


[InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.]
   Microsoft.VisualBasic.CompilerServices.Conversions.ToString(Object Value) +1287661
   productdetail.Page_Load(Object sender, EventArgs e) in D:\Websites\Maths Star\Elevenplusmathv2\productdetail.aspx.vb:40
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.4057.0