I am currently attempting to modify the way my radgrid displays data by highlighting specific rows which has went over my "overdue" limit. here's a snippet of the methods i am using..
ASPX
<
telerik:GridBoundColumn
DataField
=
"TimeCreated"
HeaderText
=
"Posted On"
ReadOnly
=
"true"
UniqueName
=
"TimeCreated"
/>
C# Method1
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
GridDataItem dataItem = e.Item
as
GridDataItem;
string
time = dataItem[
"TimeCreated"
].Text;
DateTime timePosted = DateTime.Parse(time);
TimeSpan allowance =
new
TimeSpan(0, 25, 0);
DateTime overdue = timePosted.Add(allowance);
if
(DateTime.Now > overdue)
{
dataItem.ForeColor = System.Drawing.Color.LightPink;
dataItem.Font.Bold =
true
;
}
}
C# Method 2
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
GridDataItem dataItem = e.Item
as
GridDataItem;
TimeSpan allowance =
new
TimeSpan(0, 25, 0);
if
(DateTime.Compare(Convert.ToDateTime(dataItem[
"TimeCreated"
].Text).Add(allowance), DateTime.Now) > 0)
{
dataItem.ForeColor = System.Drawing.Color.LightPink;
dataItem.Font.Bold =
true
;
}
}
C# Method 3
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
GridDataItem dataItem = e.Item
as
GridDataItem;
TimeSpan allowance =
new
TimeSpan(0, 25, 0);
if
(DateTime.Parse(dataItem[
"TimeCreated"
].Text).Add(allowance) > DateTime.Now )
{
dataItem.ForeColor = System.Drawing.Color.LightPink;
dataItem.Font.Bold =
true
;
}
}
All of these methods produces the same exact NullReferenceException which is unfathomable to me, i hope someone could shed some light on this. thanks