We have some custom webpages made by ASI, this one in particular is a list of companies. We want to be able to list their subsidiaries as a compact list. With the code I have currently inserted, which is some simple javascript and then tagged the unordered list id to match the javascript function. Anyway, this insert only works for the first company on the list when you pull up the webpage. My question is, why doesn't this work for every company in the list if they are all output recursivly by this code block? I would appreciate any help or ideas, thank you.
<script type="text/javascript" language="javascript1.2" src="http://www.piaa.us/newsbriefs/listCollapse.js"></script>
<script type="text/javascript" language="javascript1.2">
window.onload = function ()
{
compactMenu('compact',true,'± ');
}
</script>
<asp:Panel ID="resultList" runat="server">
<h2><asp:Label ID="ResultHeading" runat="server" Text="Label"></asp:Label></h2>
<asp:DataList ID="results" runat="server">
<ItemTemplate>
<ul id="compact">
<asp:LinkButton ID="link" runat="server" CssClass="titleHeader" CommandName='<%# DataBinder.Eval(Container.DataItem,"id") %>' OnCommand="detail_click">
<li><%# DataBinder.Eval(Container.DataItem, "company")%></asp:LinkButton>
<ul>
<li>Subsidiary Companys</li>
</ul>
</li>
</ul>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
ID must be unique
Probably because the ID values are not unique. Browsers/Javascript won't usually crash when you have duplicate IDs on the same page, but you get behavior like this where only the first or last item works.
Try changing something like this:
<asp:LinkButton ID="link<%# DataBinder.Eval(Container.DataItem,"ID") %>" runat="server"...
--
Bruce Wilson
Director, Technical Services
McGladrey LLP