Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 7th, 2005, 01:42 AM
Authorized User
Join Date: Aug 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get inner repeater controls in master detai


   I have a master detail display in asp.net. I am listing out categories and corresponding subcategories. Near each category there is a check box and for it's corresponding subcategories also there will be check boxes. With check box selecton I should be able to select the categories & subcategories for insertion into table. My problem is, I am getting the categoryid with checkbox selection(by counting the parent repeater items and looping through that), but I am failing to get the subcategory count and details. My output will look like


Code for repeater is

<asp:repeater id="parentRepeater" runat="server">
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<asp:CheckBox ID="chkIncld" Runat="server" Checked="true" Enabled="true"></asp:CheckBox>
<asp:Label ID="lblCategoryID" Runat="server" text='<%# Container.dataitem("CategoryID") %>' Visible="false">
<asp:repeater id="childRepeater" runat="server" datasource='<%# Container.DataItem.Row.GetChildRows("myrelation1") %>'>
<asp:CheckBox id='chksubid' SubId='<%# Container.dataitem("SD") %>' Runat="server" Checked="true" />
<asp:Label ID="lblSubCategoryID" Runat="server" text='<%# Container.dataitem("SD") %>' Visible="false">
<%# Container.DataItem("SubCategoryName") %>
</asp:repeater><asp:button id="Submit" onclick="Doit" runat="server" Width="60px" Text="Submit" Height="20px"></asp:button><asp:label id="Label1" runat="server" visible="false"></asp:label></form>

And code behind will look like

 Public Sub Doit(ByVal Source As Object, ByVal E As EventArgs)
        Dim i As Integer

        Dim iCount As Integer = parentRepeater.Items.Count - 1

        Dim _chk As Integer

        Dim _lblCateDesc As Label
        Dim _lblDescID As Label

        Dim _lblID As String

        ' Spin through all the items and add the checked Parts
        For i = 0 To iCount

            _chk = (CType(parentRepeater.Items.Item(i).FindControl("c hkIncld"), CheckBox).Checked) * -1
            _lblCateDesc = CType(parentRepeater.Items.Item(i).FindControl("lb lCategoryName"), Label)
            _lblDescID = CType(parentRepeater.Items.Item(i).FindControl("lb lCategoryID"), Label)

            If _chk = 1 Then

                _lblID = _lblDescID.Text & " , " & _lblID

            End If
End sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Child Controls of Nested Repeater... Jayahar ASP.NET 2.0 Professional 3 October 11th, 2007 01:24 PM
loop through controls and master page fraperz ASP.NET 2.0 Professional 2 June 19th, 2007 01:25 PM
Nesting Repeater controls Stricken ASP.NET 2.0 Basics 0 February 2nd, 2007 08:31 AM
Master detail with datalist or repeater ceema ASP.NET 1.0 and 1.1 Professional 0 August 30th, 2005 03:20 PM
Designing repeater controls badgolfer ASP.NET 1.0 and 1.1 Basics 2 July 18th, 2004 03:24 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.