Datalist postback issue
<p>I have a Datalist on my asp.net page with an <code>ImageButton</code> in the <code>&lt;Item Template&gt;</code>.  When an <code>ImageButton</code> is clicked, I use the <code>ItemCommand</code> event to set the border of the data item:</p>

<pre><code> protected void dlProducts_ItemCommand(object source, DataListCommandEventArgs e)
    {
        e.Item.BorderColor = System.Drawing.ColorTranslator.FromHtml("#ff5800");
        e.Item.BackColor = System.Drawing.ColorTranslator.FromHtml("#ffeee5");

    }
</code></pre>

<p>That works fine, but the border disappears when a postback occurs.  I've tried binding my datalist in the page load event like so:</p>

<pre><code>if (!Page.IsPostBack)
        {
            dlProducts.DataSource = ObjectDataSource4;
            dlProducts.DataKeyField = "Product_ID";
            dlProducts.DataBind();
        }
</code></pre>

<p>But the border is gone after a postback.  What gives?</p>

<p>Here is the datalist markup:</p>

<pre><code>&lt;asp:DataList ID="dlProducts" runat="server" CellPadding="5" CellSpacing="5"
           OnItemCommand="dlProducts_ItemCommand"
        RepeatColumns="4" RepeatDirection="Horizontal"
            ondatabinding="dlProducts_DataBinding" 
            onitemdatabound="dlProducts_ItemDataBound"  &gt;
            &lt;ItemTemplate&gt;
                &lt;asp:ImageButton ID="img" ImageAlign="Middle" runat="server" 
            ImageUrl='&lt;%# "~/uploads/profile/" + DataBinder.Eval(Container.DataItem,"ProfileImageName").ToString() %&gt;' 
            onclick="img_Click" /&gt;
            &lt;/ItemTemplate&gt;
    &lt;/asp:DataList&gt;&lt;asp:ObjectDataSource ID="ObjectDataSource4" runat="server" SelectMethod="GetAllCompetitorProducts"
        TypeName="DalProduct" OldValuesParameterFormatString="original_{0}"&gt;
        &lt;SelectParameters&gt;
            &lt;asp:SessionParameter Name="producttype_id" SessionField="ProductType_id" Type="Int32" DefaultValue="13" /&gt;
            &lt;asp:SessionParameter DefaultValue="2009" Name="Year" SessionField="Year" Type="Int32" /&gt;
        &lt;/SelectParameters&gt;
    &lt;/asp:ObjectDataSource&gt;
</code></pre>
