What is the cleanest way to make a dynamic list of buttons in asp.net?
<p>I want to change this list so that it is dynamically populated: </p>

<pre><code>&lt;ul&gt;
 &lt;li id="Tab1" class="selected" runat="server"&gt;
     &lt;asp:LinkButton ID="LinkButton1" OnClick="LinkButton1_Click"runat="server"&gt;
         Tab1 Text
     &lt;/asp:LinkButton&gt;
 &lt;/li&gt;
 &lt;li id="Tab2" runat="server"&gt;
     &lt;asp:LinkButton ID="LinkButton2" OnClick="LinkButton2_Click" runat="server"&gt;
         Tab2 Text
     &lt;/asp:LinkButton&gt;
 &lt;/li&gt;
 &lt;li id="Tab3" runat="server"&gt;
     &lt;asp:LinkButton ID="LinkButton3" OnClick="LinkButton3_Click" runat="server"&gt;
         Tab3 Text
     &lt;/asp:LinkButton&gt;
 &lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>I tried using this code:</p>

<pre><code>&lt;asp:ListView ID="ListView_Tabs" OnItemCommand="ListView_ChangeTab" runat="server"&gt;
    &lt;LayoutTemplate&gt;
        &lt;div class="tabs"&gt;
            &lt;ul&gt;
                &lt;li id="itemPlaceholder" runat="server" /&gt;
            &lt;/ul&gt;
        &lt;/div&gt;
    &lt;/LayoutTemplate&gt;
    &lt;ItemTemplate&gt;
        &lt;li&gt;
            &lt;asp:LinkButton Text='&lt;%# Eval("displayName") %&gt;' CommandName='&lt;%# Eval("parameterName") %&gt;' runat="server"/&gt;
        &lt;/li&gt;
    &lt;/ItemTemplate&gt;
&lt;/asp:ListView&gt;
</code></pre>

<p>and populate it in code behind:</p>

<pre><code>  ListView_Tabs.DataSource = comeClass.GetTabs();
  ListView_Tabs.DataBind();
</code></pre>

<p>But I don't see any clear way to set class='selected' to the last link I clicked ( or rather the list item that contains the link )</p>

<p>So my question is </p>

<p><strong>What is the cleanest way to make a dynamic list of buttons in asp.net, or even just in .net?</strong> </p>

<p>It doesn't have to be anything like my approach. I'm not even sure using ListView is the best approach to solve this.</p>
