Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Checkbox inside a repeater which is already inside another repeater..I want to count the selected items of the check boxes in each category.


Juice(Any 2) --> repeater
* Mango juice
* Apple Juice ->checkbox
* Orange Juice

Shake (Any 2)-->repeater
* Apple shake
* Chikku shake ->checkbox
* Orange Shake

I want to check the selected checkbox items according to the limitation given in the repeater. what should i do...i already used one checkbox list instead of the repeater and chechboxes but it is not working....How can i solve this.


XML
<asp:Repeater runat="server" ID="rptCategories"     onitemcommand="rptCategories_ItemCommand"   >
 <HeaderTemplate>

</HeaderTemplate>
<ItemTemplate>

 <a id='<%# DataBinder.Eval(Container.DataItem, "CategoryId")%>' ></a><strong>
<asp:Literal ID="litCatName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CategoryName")%>'></asp:Literal> </strong>
  (Any   <asp:Literal ID="litQuantity" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity")%>'></asp:Literal>)
 </td>
  </tr>
  <asp:Repeater runat="server" ID="rptMenuItemsInCategory" DataSource='<%# System.Data.DataRowView)Container.DataItem). Row.GetChildRows("CategoryToMenu") %>'    OnItemCommand="rptMenuItemsInCategory_ItemCommand"  >
                              <HeaderTemplate>
                              </HeaderTemplate>
                              <ItemTemplate>

                                      <asp:CheckBox ID="Chkmenu" runat="server" OnCheckedChanged="Chkmenu_checkchanged" AutoPostBack="true" />

                                      <asp:Label ID="lblitemname" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "[\"ItemName\"]")%>'></asp:Label>
                                      <asp:HiddenField ID="hidmenuid" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "[\"MenuId\"]")%>' />
                                      <asp:HiddenField ID="hidCatname" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "[\"CategoryName\"]")%>' />
                                      <asp:HiddenField ID="hidCatId" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "[\"CategoryId\"]")%>' />

                              </ItemTemplate>
                              <FooterTemplate>

                              </FooterTemplate>
                            </asp:Repeater>    </table>
                        </td>
                      </tr>
                    </ItemTemplate>
                    <FooterTemplate>

                      </table>
                    </FooterTemplate>
                  </asp:Repeater>
Posted
Updated 27-Oct-13 22:04pm
v5
Comments
Mahesh Bailwal 26-Oct-13 9:34am    
Can you tell what approach you have used to get selected items.?
Member 9492907 28-Oct-13 1:34am    
foreach (RepeaterItem item in rptCategories.Items)
{


Repeater rptMenuItemsInCategory = item.FindControl("rptMenuItemsInCategory") as Repeater;
if (rptMenuItemsInCategory != null)
{
foreach (RepeaterItem citem in rptMenuItemsInCategory.Items)
{
CheckBox Chkmenu = (CheckBox)citem.FindControl("Chkmenu");
if (Chkmenu.Checked == true)
{
}
}
}
}

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900