Solved

How do I resolve "A control cannot modify its parents' control collections."

Posted on 2008-06-16
8
328 Views
Last Modified: 2008-06-21
I am trying to nest two data repeaters... and I cannot figure out why ((System.Data.DataRowView)Container.DataItem)["studID"] is not working in the second repeater.  I keep getting "A control cannot modify its parents' control collections."  I've been searching for clues for the last two hours with no luck.  

I've been using this msdn article as a reference:

http://support.microsoft.com/kb/326338

How can do I pull the DataItem out of the child repeater?



<asp:Repeater id="rptrMasterList" runat="server">
		<HeaderTemplate>
			<p><strong>Header</strong><br />
		</HeaderTemplate>
		<ItemTemplate>
			<h1><a href="javascript:void(0)" class="dsphead" onclick="dsp(this)"> <span  class="dspchar">
					+</span> <%# DataBinder.Eval(Container.DataItem, "schLabel") %></a></h1>
			<asp:Repeater id="rptrSubmitted" Runat="server" datasource='<%# ((System.Data.DataRowView)Container.DataItem).Row.GetChildRows("myRelation")  %>'>
				<HeaderTemplate>
						<div class="dspcont"> StudID: 
				</HeaderTemplate>
				<ItemTemplate>
					<%# ((System.Data.DataRowView)Container.DataItem)["studID"]  %>
 
				</ItemTemplate>
				<SeparatorTemplate>
				</SeparatorTemplate>
				<FooterTemplate>
					</div>
				</FooterTemplate>
			</asp:Repeater>
		</ItemTemplate>
		<SeparatorTemplate>
		</SeparatorTemplate>
		<FooterTemplate>
		</FooterTemplate>
	</asp:Repeater>

Open in new window

0
Comment
Question by:eromanowski
  • 4
  • 4
8 Comments
 
LVL 6

Accepted Solution

by:
cottsak earned 500 total points
ID: 21798881
i had to nest repeaters only the other week. i used this for reference - http://www.asp.net/learn/data-access/tutorial-32-cs.aspx
it's working now with a few mods. take a read and let me know if you have any more questions. :D
0
 

Author Comment

by:eromanowski
ID: 21803149
Did I mention I have to do this in 1.1?  I'm pretty sure Eval() is new to 2.0.  That is a good guide though.
0
 
LVL 6

Expert Comment

by:cottsak
ID: 21809198
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:eromanowski
ID: 21814478
Ah, yes, you are correct.  Databinder.Eval() and Eval() are the same function.  I have yet to resolve my issue.  My code is identical the this article:  http://www.asp.net/learn/data-access/tutorial-32-cs.aspx.  The only difference is mine was developed in C#.  

0
 

Author Comment

by:eromanowski
ID: 21815771
Oh, I just realized I posted the wrong article:

Here's the correct link, my apologies:  

http://support.microsoft.com/kb/326338

0
 
LVL 6

Expert Comment

by:cottsak
ID: 21827860
the reason i suggested that article above is because it approaches the task with two options: declarative binding and programmatic binding. truth be told, i never got the declarative binding working... i thought my code was as close to the example as i could get it, yet it still didnt work (i couldnt remember the exact errors i was having). the point is that i cant see any obvious issue with ur code but the task seems so similar to my situation that you may find it's easier to take a different approach and get it working than wasting countless hours trying to get Plan A to work. [IMHO]
0
 

Author Comment

by:eromanowski
ID: 21831993
Yeah I wouldn't recommend trying to take my approach, you will waste countless hours.  Thank you Microsoft for providing a useless article on nested repeaters.  =)

0
 
LVL 6

Expert Comment

by:cottsak
ID: 21836847
i try to use MS' resources last - when nothing elase works. they are pretty crappy
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
2 questions 10 25
FTP file download using c# 3 23
Question about JQuery and asp.net 3 27
Connection to multiple databases 13 19
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question