Server Error in '/' Application.

Object cannot be cast from DBNull to other types.

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: Object cannot be cast from DBNull to other types.

Source Error:


Line 143:    string _tillfalle_dt(RepeaterItem item)
Line 144:    {
Line 145:        DateTime _dt = Convert.ToDateTime(_r(item, "datum"));
Line 146:        return string.Format("{0} {1}", _dt.Day, _dt.ToString("MMM yyyy"));
Line 147:    }

Source File: c:\fakta_www\sp2010\df\modules\utbildning\tillfalle_2.ascx    Line: 145

Stack Trace:


[InvalidCastException: Object cannot be cast from DBNull to other types.]
   System.DBNull.System.IConvertible.ToDateTime(IFormatProvider provider) +52
   System.Convert.ToDateTime(Object value) +32
   ASP.modules_utbildning_tillfalle_2_ascx._tillfalle_dt(RepeaterItem item) in c:\fakta_www\sp2010\df\modules\utbildning\tillfalle_2.ascx:145
   ASP.modules_utbildning_tillfalle_2_ascx.__DataBind__control3(Object sender, EventArgs e) in c:\fakta_www\sp2010\df\modules\utbildning\tillfalle_2.ascx:185
   System.Web.UI.Control.OnDataBinding(EventArgs e) +84
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +150
   System.Web.UI.Control.DataBind() +17
   System.Web.UI.Control.DataBindChildren() +185
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +160
   System.Web.UI.Control.DataBind() +17
   System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +126
   System.Web.UI.WebControls.Repeater.AddDataItemsIntoItemsArray(IEnumerable dataSource, Boolean useDataSource) +217
   System.Web.UI.WebControls.Repeater.PostGetDataAction(IEnumerable dataSource) +71
   System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +220
   System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +62
   System.Web.UI.WebControls.Repeater.DataBind() +77
   dfk.modules.utbildning.tillfalle._bind() +400
   dfk.modules.utbildning.tillfalle.AttachChildControls() +191
   spbase.controls.TemplatedWebControl.CreateChildControls() +483
   System.Web.UI.Control.EnsureChildControls() +92
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +883


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