Solved

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

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

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
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.

766 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