How to assign dynamic css class to HyperLink located inside ListView
<p>Kinda of confusing title.</p>

<p>This is my old navigation</p>

<pre><code>&lt;li&gt;&lt;a href="General.aspx" runat="server" id="currentGeneral"&gt;&lt;i class="home"&gt;&lt;/i&gt; Overview&lt;/a&gt;&lt;/li&gt;
</code></pre>

<p>The i class sets an icon next to the navigation tab. </p>

<p>On the Site.Master.CS I checked what the current page was and would set it to active with the code below.</p>

<pre><code>currentGeneral.Attributes["class"] = "active";
</code></pre>

<p>So I changed the navigation to a listview populated by a database.</p>

<pre><code>&lt;asp:ListView ID="ListViewMenu" runat="server" ItemPlaceholderID="menuContainer"&gt;

&lt;LayoutTemplate&gt;
    &lt;ul class="menu" id="responsive" runat="server"&gt;
        &lt;asp:PlaceHolder ID="menuContainer" runat="server" /&gt;
    &lt;/ul&gt;
&lt;/LayoutTemplate&gt;

&lt;ItemTemplate&gt;
&lt;li&gt;&lt;a href='&lt;%#Eval ("href") %&gt;' class='&lt;%#Eval ("id") %&gt;'&gt; &lt;i class='&lt;%#Eval ("class") %&gt;'&gt;&lt;/i&gt;&lt;%#Eval ("text") %&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ItemTemplate&gt;

&lt;/asp:ListView&gt;
</code></pre>

<p>But now that I am using listview, the currentGeneral id does not exist and I cant set it to active.</p>

<p>I was trying to think what the best way to get this to work is. Anyone have a suggestion?</p>

<p>Thank you.</p>
