Hi All,
I'm generating a folder tree with the following repeater. It creates a parent using the database values, AreaID for the parent and SubID for child objects, hiding and unhiding a div layer to show the child objects with a javascript function that works fine.
What I'm trying to do and am having trouble with is that I want to be able to check the check box for the parent, have all the child check boxes checked = True and vice versa when unchecking the parent have all the child checkboxes.checked = False.
Code:
<asp:Repeater ID="rptAreas" Runat="server">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td valign="top">
<img border="0" src="/images/icons/spacer.gif" width="16" height="2" /><br />
<img border="0" src="/images/icons/max_sm.gif" width="16" height="16" align="absmiddle" name="_Area<%#DataBinder.Eval(Container.DataItem, "AreaID")%>" alt="Maximize" onclick="javascript:showHide('Area<%#DataBinder.Eval(Container.DataItem, "AreaID")%>');" /><br />
</td>
<td>
<asp:CheckBox ID="chkAreaID" AutoPostBack="True" OnCheckedChanged="chkAreaID_CheckedChanged" Runat="server" />
<b><%#DataBinder.Eval(Container.DataItem, "AreaName")%></b><br />
<div id="Area<%#DataBinder.Eval(Container.DataItem, "AreaID")%>" class="hide">
<asp:CheckBoxList ID="cblSubID" CellPadding="0" CellSpacing="0" Runat="server" />
</div>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I can see in the source of the web page that there are ID's generated:
<input id="rptAreas__ctl9_chkAreaID" type="checkbox" name="rptAreas:_ctl9:chkAreaID" onclick="__doPostBack('rptAreas$_ctl9$chkAreaID',' ')" language="javascript" />
<input id="rptAreas__ctl9_cblSubID_0" type="checkbox" name="rptAreas:_ctl9:cblSubID:0" checked="checked" />
So I'm thinking there might be a way to access those ctl numbers and whether or not say for the above examples I'd be looking INSTR for the ID 'ctl9' and all of the SubID's generated for that parent.
I don't even know if I'm going about this in the right way. Please, any suggestions would be greatly appreciated. And even if I am going in the right direction how to access those names or ID's.
Thank you,
Richard