I have a table bound to a repeater. There is a DateTime column called
EntryDate. When the EntryDate changes day [when CompareDates() is true]
I want to write the date out. I want to compare the value of an item
from a table column with a public variable and then set the variable to
the value of that item when the days change [CompareDates() will do
this provided it ]
Can I access the value of EntryDate column? If so how? Clearly not by
using Eval because that requires me to bind it so something which I
don't want to do.
It compiles and gives a runtime error:
Databinding methods such as Eval(), XPath(), and Bind() can only be
used in the context of a databound control.
If it's possible to fix the code below, how so?
<% if (CompareDates(D ateStored, Eval("EntryDate ")))
{
DateStored = (DateTime)Eval( "EntryDate" );
%>
</table>
<div class='TabBar'>
<span id='tabDate1' class='TabLeft' ><%#
Convert.ToDateT ime(DataBinder. Eval(Container. DataItem,
"EntryDate")).T oString("ddd MMM dd yyyy") %></span>
<span class='TabRight Blank'></span>
</div>
<table cellspacing="2" class="DayGroup ">
<%} %>
// code behind
public bool CompareDates(Da teTime dateStored, object entryDate)
{
DateTime et;
if (entryDate is DBNull)
return false;
else
{
et = (DateTime)entry Date;
return (new DateTime(DateSt ored.Year, DateStored.Mont h,
DateStored.Day) new DateTime(et.Yea r, et.Month, et.Day));
}
}