473,387 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem: Nested Repeater won't databind()?

Platform: ASP.NET 1.1

I have a repeater nested inside another repeater. My outer repeater is
looping fine. I am manually binding the inner repeater to a DataReader
obtained from another function.

My objects aren't null, my ItemDataBound() method is being called, and as
you can see I have verified that I have data.

Yet, the repeater does not appear in the final HTML, and what's more, after
the DataBind() call, the .Items.Count property is still 0. What am I doing
wrong?

Here is the code (I apologise for any text wrapping - is there a way to turn
that off?):

//------------------------------------------
protected void OuterRepeater_ItemDataBound( object sender,
System.Web.UI.WebControls.RepeaterItemEventArgs e )
{

System.Web.UI.WebControls.ListItemType lt = e.Item.ItemType ;

if ( lt == System.Web.UI.WebControls.ListItemType.Item ||
lt == System.Web.UI.WebControls.ListItemType.Alternating Item )
{

System.Web.UI.WebControls.Repeater innerRepeater ;

System.Data.Common.DbDataRecord dr = e.Item.DataItem as
System.Data.Common.DbDataRecord ;
if ( dr != null)
{
string cChildKeyValue = dr["CHILD_KEY"].ToString() ;

System.Data.SqlClient.SqlDataReader oReader =
this.getChildDataFor( cChildKeyValue ) ;
if ( oReader != null )
{
innerRepeater = e.Item.FindControl("InnerRepeater") as
Repeater ;
if ( rptrGlassPart != null )
{
// Prove we have the right data:
if ( false ) {
while( oReader.Read() )
{
Response.Write( "<div>Data: " +
oReader.GetString(0) + "</div>" );
}
}
else {
// These statements appear to have no effect.
// The repeater is not rendered in the output HTML:

innerRepeater.DataSource = oReader ;
innerRepeater.DataBind() ;

// innerRepeater.Items.Count = 0 at this point.
}
}
else {
Response.Write("<div>innerRepeater is null.</div>") ;
}
oReader.Close();
}
}
}
}
//------------------------------------------

Thanks in advance,
- Colin
Nov 19 '05 #1
2 2115
I can't say that I see anything inherently wrong, I imagine that the
innerRepeater is actually named rptrGlassPart as you still have a reference
to it in your code. You could use some better try/catch and god only
knows where your connections are being closed for the inner repeater's
datareader...but that shouldn't be a problem. I'd also wonder if using a
dataset with 2 datatables and a DataRelation wouldn't make things more clear
(and maybe even more performant) but again I can't see that as being the
actual problem.

Perhaps its soemthing wrong with the html side of the repeater?

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Colin Nicholls" <co***@spacefold.com> wrote in message
news:eT****************@TK2MSFTNGP12.phx.gbl...
Platform: ASP.NET 1.1

I have a repeater nested inside another repeater. My outer repeater is
looping fine. I am manually binding the inner repeater to a DataReader
obtained from another function.

My objects aren't null, my ItemDataBound() method is being called, and as
you can see I have verified that I have data.

Yet, the repeater does not appear in the final HTML, and what's more, after the DataBind() call, the .Items.Count property is still 0. What am I doing
wrong?

Here is the code (I apologise for any text wrapping - is there a way to turn that off?):

//------------------------------------------
protected void OuterRepeater_ItemDataBound( object sender,
System.Web.UI.WebControls.RepeaterItemEventArgs e )
{

System.Web.UI.WebControls.ListItemType lt = e.Item.ItemType ;

if ( lt == System.Web.UI.WebControls.ListItemType.Item ||
lt == System.Web.UI.WebControls.ListItemType.Alternating Item )
{

System.Web.UI.WebControls.Repeater innerRepeater ;

System.Data.Common.DbDataRecord dr = e.Item.DataItem as
System.Data.Common.DbDataRecord ;
if ( dr != null)
{
string cChildKeyValue = dr["CHILD_KEY"].ToString() ;

System.Data.SqlClient.SqlDataReader oReader =
this.getChildDataFor( cChildKeyValue ) ;
if ( oReader != null )
{
innerRepeater = e.Item.FindControl("InnerRepeater") as
Repeater ;
if ( rptrGlassPart != null )
{
// Prove we have the right data:
if ( false ) {
while( oReader.Read() )
{
Response.Write( "<div>Data: " +
oReader.GetString(0) + "</div>" );
}
}
else {
// These statements appear to have no effect.
// The repeater is not rendered in the output HTML:
innerRepeater.DataSource = oReader ;
innerRepeater.DataBind() ;

// innerRepeater.Items.Count = 0 at this point.
}
}
else {
Response.Write("<div>innerRepeater is null.</div>") ;
}
oReader.Close();
}
}
}
}
//------------------------------------------

Thanks in advance,
- Colin

Nov 19 '05 #2
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:e3****************@tk2msftngp13.phx.gbl...
I can't say that I see anything inherently wrong, I imagine that the
innerRepeater is actually named rptrGlassPart as you still have a
reference to it in your code.
oops! Yes, sorry, I simplified the posted code and missed a reference.

You could use some better try/catch and god only
knows where your connections are being closed for the inner repeater's
datareader...but that shouldn't be a problem.
I took out some of the try/catch and debug code for simplification. The
connections (several in total) are all being closed in Page_Unload().

I'd also wonder if using a dataset with 2 datatables and a DataRelation
wouldn't make things more clear (and maybe even more performant) but
again I can't see that as being the actual problem.
My associate suggested that as well, but this is a simplified case of a
multi-child entity problem so changing to related data sets wouldn't solve
everything. I just felt that this should work - inefficient as it may be -
and it wasn't.

Perhaps its soemthing wrong with the html side of the repeater?


If so, I can't figure it out. I have other (not nested) repeaters elsewhere
in my aspx that are working fine, binding to DataReaders using the same
mechanism.

Thanks for verifying that it's not a simple newbie error. I have several
options to try.

1) bind the innerRepeater to a dataset instead of a reader (who knows? might
work)

2) use an inner DataGrid instead of a Repeater, bind it to the Reader
(ditto)

3) work up a REALLY simple nested Repeater example to see if it shows the
same problem.

Thanks again, Karl,
- Colin

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ed Allan | last post by:
http://ejaconsulting.com/nestedrepeater/NestedRepeater.txt >-----Original Message----- >Doh! The HTML has all been rendered . . . > >Right click on this link and select 'Save target as ..' >to...
2
by: Stephen Miller | last post by:
I am using the OnItemDataBound event of Repeater control to nest a DataGrid within the Repeater. When I attempt to bind to the DataGrid using the DataSource method I get the error message "Object...
0
by: Patrik Persson | last post by:
Hello all I have got a problem with a nested repeater and the ItemCommand Event. I am adding handler for the ItemCommand and ItemBound. The ItemBound works perfect but I cant seem to get the...
1
by: Maziar Aflatoun | last post by:
Hi, I have tried setting up a nested repeater control and it works fine. But when I do 3 level nested repeater it fails. Does anyone know a site or have an example of a three level nestest...
3
by: Eirik Eldorsen | last post by:
Im trying to make a nested repeater with 3 levels. I've successfully created a nested repeater with 2 levels, but when adding the 3rd level I get an InvalidCastException. What am I doing wrong? ...
3
by: sorCrer | last post by:
Hi All, Posted after extensive searching! I have a nested repeater control as follows: (Simplified ;-)) <table> <asp:repeater id=parent onItemDataBound=createChild> <tr><td>Level...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
4
by: =?Utf-8?B?SmFtZXMgR2V1cnRz?= | last post by:
On my page, I have one repeater that contains a literal control and a nested repeater. The nested repeater contains a literal control. Both repeaters are databound with only one object (string). ...
2
by: ASF | last post by:
Hey all, I have a gridview which pulls from a BLL which pulls from a DAL (an .XSD file). Each row on that gridview has a nested repeater which pulls from another table. The code which populates...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.