For some reason i am getting an object refrence not set to an instance of an object.
Protected Sub GridView6_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
Dim date1 As Date
date1 = Date.Now
Dim date2 As Date
Dim ddate As Label = CType(e.Row.FindControl("label1"), Label)
date2 = Date.Parse(ddate.Text)
Dim ts As TimeSpan = date2.Subtract(date1)
Dim days As Integer = ts.TotalDays
If days <= 14 Then
e.Row.ForeColor = System.Drawing.Color.Red
ElseIf days > 14 And ts.Days < 30 Then
e.Row.ForeColor = System.Drawing.Color.Blue
ElseIf days >= 30 Then
e.Row.ForeColor = System.Drawing.Color.LightGreen
End If
End Sub
Object reference not set to an instance of an object. 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.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 166: Line 167: Dim ddate As Label = CType(e.Row.FindControl("label1"), Label) Line 168: date2 = Date.Parse(ddate.Text) Line 169: Dim ts As TimeSpan = date2.Subtract(date1) Line 170: Dim days As Integer = ts.TotalDays
Source File: C:\Documents and Settings\ChrisH\Desktop\AJAXEnabledWebSite18\Default.aspx.vb Line: 168
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] _Default.GridView6_RowDataBound(Object sender, GridViewRowEventArgs e) in C:\Documents and Settings\ChrisH\Desktop\AJAXEnabledWebSite18\Default.aspx.vb:168 System.Web.UI.WebControls.GridView.OnRowDataBound(GridViewRowEventArgs e) +108 System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +167 System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +1651 System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57 System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +14 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73 System.Web.UI.WebControls.GridView.DataBind() +4 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82 System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +22 System.Web.UI.WebControls.GridView.OnPreRender(EventArgs e) +17 System.Web.UI.Control.PreRenderRecursiveInternal() +80 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842