ASP.NET C#, Access div element from nested Listview Code Behind
<p>I'm trying to get the (div id="imgGallery" runat="server") element from nested Listview to modify the class name programatically.</p>

<pre><code>&lt;asp:ListView ID="ListView1" runat="server" ItemPlaceholderID="itemPlaceHolder1" onitemdatabound="ListView1_ItemDataBound"&gt;
&lt;ItemTemplate&gt;
    &lt;asp:Label ID="VersionId" runat="server" Text='&lt;%# Eval("VersionId") %&gt;' Visible="false" /&gt;
    &lt;asp:Label ID="MenuContent" runat="server" Text='&lt;%# Eval("ContentText") %&gt;' /&gt;
    &lt;br /&gt;
    &lt;asp:ListView ID="ListView2" runat="server" ItemPlaceholderID="itemPlaceHolder2"&gt;
        &lt;ItemTemplate&gt;
            &lt;div id="imgGallery" class="images" runat="server"&gt;
                &lt;asp:Image ID="Image1" ImageUrl='&lt;%# Eval("ImageUrl") %&gt;' runat="server" ToolTip="Text" /&gt;
            &lt;/div&gt;
        &lt;/ItemTemplate&gt;
        &lt;LayoutTemplate&gt;
            &lt;asp:PlaceHolder runat="server" ID="itemPlaceHolder2"&gt;&lt;/asp:PlaceHolder&gt;
        &lt;/LayoutTemplate&gt;
    &lt;/asp:ListView&gt;
&lt;/ItemTemplate&gt;
&lt;LayoutTemplate&gt;
    &lt;asp:PlaceHolder runat="server" ID="itemPlaceHolder1"&gt;&lt;/asp:PlaceHolder&gt;
&lt;/LayoutTemplate&gt;
&lt;ItemSeparatorTemplate&gt;
    &lt;br /&gt;
    &lt;hr /&gt;
    &lt;br /&gt;
&lt;/ItemSeparatorTemplate&gt;
</code></pre>

<p></p>

<p>on my code behind I tried the code below which doesn't work... and I tried different ways but can't find solution.</p>

<pre><code>    ListView listView2 = (ListView)ListView1.FindControl("ListView2");
HtmlGenericControl mydiv = (HtmlGenericControl)listView2.FindControl("imgGallery");
mydiv.Attributes.Clear();
</code></pre>
