Set style properties to a div in listview
<p>I have a page with a listview, which has a div. This div has different background color according the database info:</p>

<pre><code> &lt;asp:ListView ID="lvwPostArt" runat="server" DataSourceID="odsAdvanced" GroupItemCount="3" OnItemDataBound="lvwPostArt_ItemDataBound"&gt;
        &lt;EmptyDataTemplate&gt;
            &lt;p&gt;No matches.&lt;/p&gt;
        &lt;/EmptyDataTemplate&gt;
        &lt;LayoutTemplate&gt;
            &lt;table style="border: none"&gt;
                &lt;asp:PlaceHolder ID="groupPlaceholder" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
            &lt;/table&gt;
        &lt;/LayoutTemplate&gt;
        &lt;GroupTemplate&gt;
            &lt;tr&gt;
                &lt;asp:PlaceHolder runat="server" ID="itemPlaceholder"&gt;&lt;/asp:PlaceHolder&gt;
            &lt;/tr&gt;
        &lt;/GroupTemplate&gt;
        &lt;ItemTemplate&gt;
            &lt;td&gt;
            &lt;!--HEEEEEEEERE'S THE DIV!!! --&gt;
                &lt;div id="divContainer" class="icondetail" runat="server" style='background-color:&lt;%# Eval("colorFondo") %&gt;'&gt;&lt;!-- HERE GOES CUSTOM COLOR --&gt;
                        &lt;div class="innerBox"&gt;
                            &lt;asp:Image runat="server" ID="img_Post" ImageUrl='&lt;%# Eval("ImageThumbnail") %&gt;' CssClass="StaticImage" /&gt;
                        &lt;/div&gt;
                &lt;/div&gt;
            &lt;/td&gt;
        &lt;/ItemTemplate&gt;
    &lt;/asp:ListView&gt;
</code></pre>

<p>However this is not receiving the color. the objectDataSource has the following DataObjectTypeName:</p>

<pre><code>public class myImage
{
    string colorFondo { get; set; }
    string ImageThumbnail { get; set; }
}
</code></pre>

<p>Here is what I tried so far:</p>

<p>Try #1: Set the databind directly on the div style.</p>

<pre><code>&lt;div id="divContainer" class="icondetail" runat="server" style='background-color:&lt;%# Eval("colorFondo") %&gt;'&gt;
</code></pre>

<p>Try #2: Set the information on code behind by using the property ItemDataBound</p>

<pre><code>protected void lvwPostArt_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        ListViewDataItem dataItem = (ListViewDataItem)e.Item;

        if (e.Item.ItemType == ListViewItemType.DataItem)
        {
            HtmlGenericControl divCont = (HtmlGenericControl)e.Item.FindControl("divContainer");
            divCont.Style.Add("background-color", "#ffffff"); //How can I get the info from the DataClass to assign it to the property????
        }
    }
</code></pre>

<p>My question is, how can I assign a background-color to this div?</p>
