Select all checkboxes in child repeater
hi guys
i'm trying to select all checkboxes in a child repeater, but i am having some
difficulty.
I have a checkbox in my HeaderTemplate, that when clicked must check all
checkboxes in my ItemTemplate, All of this is in a child repeater.
here's the simplified aspx page:
Code:
<asp:Repeater id="rpActiveCategory" runat="server" OnItemDataBound="rpActiveCategory_OnItemDataBound">
<ItemTemplate>
<asp:Repeater ID="rpActiveSpecs" runat="server" OnItemDataBound="rpActiveSpecs_OnItemDataBound" OnItemCommand="rpActiveSpecs_OnItemCommand">
<headertemplate>
<asp:CheckBox ID="cbActiveMain" runat="server" OnCheckedChanged="OnCheckedChanged_cbActiveMain" AutoPostBack="true" />
</headertemplate>
<ItemTemplate>
<asp:CheckBox ID="cbActive" runat="server" Enabled="true" /> And here is code for 'OnCheckedChanged_cbActiveMain':
Code:
Public Sub OnCheckedChanged_cbActiveMain(ByVal s As Object, ByVal e As EventArgs)
Dim myCheckBox As CheckBox = s
Dim rpActiveCategory As Repeater = myCheckBox.Parent.Parent.Parent.Parent.Parent
Dim rpActiveCategoryItem As RepeaterItem = myCheckBox.Parent.Parent.Parent.Parent
Dim rpActiveSpecs As Repeater = myCheckBox.Parent.Parent
Dim rpActiveItem As RepeaterItem = myCheckBox.Parent
Dim cbActiveMain As CheckBox = rpActiveItem.FindControl("cbActiveMain")
Dim cbActive As CheckBox
For Each categoryItem As RepeaterItem In rpActiveCategory.Items
For Each item As RepeaterItem In rpActiveSpecs.Items
cbActive = rpActiveItem.FindControl("cbActive")
cbActive.Checked = True
Next
Next
End Sub
the prob is that my code can't reference cbActive? gives ma an Object Null Reference.
any ideas, am i going about this in the right way?
Shem
Shem, November 3rd, 2008 05:59 AM
Bookmarks