Asp.net: how to compare DataBinder.Eval with a member variable?
<p>I am trying to do this in a repeater:</p>

<pre><code>&lt;%# Iif((int)DataBinder.Eval(Container.DataItem, "Id") == SelectedJobDefId, "blue", "red")%&gt;
</code></pre>

<p>Problem is that the member property only evaluates if this syntax is used:</p>

<pre><code>&lt;%= SelectedJobDefId %&gt;
</code></pre>

<p>DataBinder.Eval() only works if the hash symbol is used. </p>

<p>As a test, I tried this:</p>

<pre><code>  &lt;%= SelectedJobDefId %&gt;
  &lt;%# DataBinder.Eval(Container.DataItem, "Id") + " " + SelectedJobDefId %&gt;
</code></pre>

<p>The first SelectedJobDefId stays correct as I switch rows (LinkButton event). 
The DataBinder part is correct for each row. 
The 2nd output of SelectedJobDefId is always "1".</p>

<p>How can I compare these two values?</p>

<p>UPDATE:</p>

<p>Based on the suggestion by Jeremy, I made the td a server tag and tried to do the logic in OnItemDataBound like this:</p>

<pre><code>protected void Repeater2_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        RepeaterItem item = e.Item;
        DataRowView drv = (DataRowView)item.DataItem;

        int id = (int)drv.Row.ItemArray[0];

        HtmlTableCell td = (HtmlTableCell)item.FindControl("failtd");

        if (id == this.SelectedJobDefId){td.BgColor = "green";}
    }
</code></pre>

<p>When I step through the debugger, the OnItemDataBound event is happening <strong>before</strong> the LinkButton event that updates the SelectedJobDefId property which explains the default value of 1.</p>

<p>Is there a way to switch the order of events? I may just be taking the wrong approach.</p>
