Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all,

 

I have a ItemDataBound event that changes the colour of my row text if depending on the date IE one of my items in the list is overdue. It all works fine except for the actual if statement. The compiler keeps jumping to the second if statement even though the dates are equal (I can see them in the debugger, exactly the same).

 

<code>

if (TodaysDate > tmpDate)

</code>

 

 

Its an enigma. I thought maybe I've done something wrong with the way in which I've used the if statements and maybe it needs to be done differently withs dates. Any ideas would be most appreciated.

 

<code>

private void C1WebGrid1_ItemDataBound(object sender, C1.Web.C1WebGrid.C1ItemEventArgs e)

{

C1ListItemType lit = e.Item.ItemType;

String jobDueByDate;

DateTime TodaysDate = System.DateTime.Now;

 

if (lit == C1ListItemType.Item || lit == C1ListItemType.AlternatingItem)

{

DataRowView drv = (DataRowView) e.Item.DataItem;

jobDueByDate = drv[JobData.DUE_DATE_FIELD].ToString();

 

DateTime tmpDate = Convert.ToDateTime(jobDueByDate);

 

if (TodaysDate == tmpDate) // This job is to be done today

{

e.Item.BackColor = System.Drawing.Color.Blue;

}

 

if (TodaysDate > tmpDate) // This job is overdue

{

e.Item.ForeColor = System.Drawing.Color.Red;

}

 

}

}

 

</code>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...