单独的CHECKBOX与CHECKBOXLIST里面的项目成父子关系
现在有两个问题:
第一个问题:在客户端选中作为单独的CHECKBOX,用客户端脚本同时选中CHECKBOXLIST中的所有项目
第二个问题:选中CHECKBOXLIST中的任何一个项目,将同时选中单独的CHECKBOX第一个问题俺已经解决
第二个问题非常难,因为,没有办法为CHECKBOXLIST中的子项来添加客户端事件处理函数求助各位
现在有两个问题:
第一个问题:在客户端选中作为单独的CHECKBOX,用客户端脚本同时选中CHECKBOXLIST中的所有项目
第二个问题:选中CHECKBOXLIST中的任何一个项目,将同时选中单独的CHECKBOX第一个问题俺已经解决
第二个问题非常难,因为,没有办法为CHECKBOXLIST中的子项来添加客户端事件处理函数求助各位
贴一小段代码给大家
<asp:repeater id="TbBuyerFocus" runat="server" EnableViewState="False">
<ItemTemplate>
<table width="100%" border="1" cellpadding="1" cellspacing="0" bordercolor="#ff6600">
<tr>
<td bgcolor="SandyBrown" height="25">
<asp:Label ID="IndustryName" Runat="server" Font-Bold="true" Font-Size="11pt"><%# DataBinder.Eval(Container.DataItem,"Industry")%></asp:Label>
</td></tr>
<tr>
<td style="font-size:9pt">
<asp:repeater ID="CategoryList" Runat="server" DataSource='<%# GetCategoryList(Int32.Parse(DataBinder.Eval(Container.DataItem,"id").ToString()))%>' OnItemDataBound="CategoryList_ItemDataBound">
<ItemTemplate><br>
<asp:CheckBox ID="Category" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"CategoryName") %>' Font-Bold="true" TextAlign="right" ForeColor="red"></asp:CheckBox>
<hr size="1" color="#aaaaaa" noshade>
<asp:CheckBoxList ID="SubCategoryList" Runat=server RepeatColumns="5" DataSource='<%# GetSubCategoryList(Int32.Parse(DataBinder.Eval(Container.DataItem,"Id").ToString()))%>' DataTextField="SubCategoryName" DataValueField="SubcategoryName" RepeatDirection="Horizontal" RepeatLayout="Table" ></asp:CheckBoxList>
</ItemTemplate>
</asp:repeater>
</td></tr>
</table>
<br>
</ItemTemplate>
</asp:repeater>已经绑定好了,现在问题是这样,我想处理嵌入的CHECKBOXLIST中的项目的CLICK事件,然后,只要选中CHECKBOXLIST中的任一项,就会选中ID为CATEGORYLIST的CHECKBOX问题是CHECKBOXLIST好像不能为每一项来指定客户端事件处理脚本
CHECKBOXLIST.Attrbutes.Add("onclick","javascript:window.document.all["checkboxname"].checked=true;");
它生成的CHECKBOX是由一个表格(表格的ID就是CHECKBOXLIST的ID)
和嵌在单元格中的CHECKBOXLIST构成的所以,用楼上兄弟的办法,如果你点击了表格的任何一个部位,都会导致单独的CHECKBOX被选中