Solved

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

Posted on 2008-06-16
8
325 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
 

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now