title: Add CSS Class through a Repeater
body: <p>I have a repeater which dynamically generate tab links using Sitecore (sc:Link) like this:</p>
  
  <pre><code>&lt;asp:Repeater ID="rptTab" runat="server" OnItemDataBound="rptTab_ItemBound"&gt;
              &lt;ItemTemplate&gt;
                  &lt;li id= "liTabTest" runat = "server" class="tab-label"&gt;
                      &lt;asp:HyperLink onclick = "javascript: TabClick(this)" runat="server" id="aLink"&gt;
                          &lt;sc:Link ID="hlTabLink" Field="scTabLink" runat="server" &gt;&lt;/sc:Link&gt;
                      &lt;/asp:HyperLink&gt;
                  &lt;/li&gt;
              &lt;/ItemTemplate&gt;
         &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>I manipulate the CSS via JS:</p>
  
  <pre><code>var loadURL;
  $(document).ready(function () {
      init();
  });
  
  function init() {
       $("ul#Tab-labels li:first").addClass("TabbedPanelsTabSelected");
    };
  
    function TabClick(obj) {
        $("ul#Tab-labels li").removeClass("TabbedPanelsTabSelected");
        $(obj).addClass("TabbedPanelsTabSelected");
  
   };
  </code></pre>
  
  <p>Unfortunately, this is not working because each tab is a separate .ASPX page, so the page is getting rendered again and that is why Init() in JS is getting called and CSS is getting executed to the first item everytime. </p>
  
  <p>This is my code behind:</p>
  
  <pre><code>        protected void rptTab_ItemBound(Object sender, RepeaterItemEventArgs e)
      {
          if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
          {
              Item i = e.Item.DataItem as Item;
              Link hlTabLink = e.Item.FindControl("hlTabLink") as Link;
              hlTabLink.DataSource = i.Paths.FullPath;
              hlTabLink.Field = "Title";
              HyperLink aLink = e.Item.FindControl("aLink") as HyperLink;
              aLink.NavigateUrl = Sitecore.Links.LinkManager.GetItemUrl(i);
          }
      }
  </code></pre>
  
  <p>I tried adding CSS through code-behind but it didnt work because I cannot get the index of the tab (which tab is getting selected). Any solution will be appreciated! Thanks!</p>