473,854 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bug with nested repeaters. Item events are called twice per item

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). But... and this is the crappy
part, the nested repeater's events are fired twice. How do I know this? I
setup global private counter variables that get incremented on the repeater's
ItemDataBound event. The outer repeater is correct and only calls the
ItemDataBound event once for each item, but the inner nested repeater calls
it's ItemDataBound event twice for each item.

It's worth mentioning that I did set AutoEventWireup to false, just in case...

You can review the markup and code or download the code
(http://www.biasecurities.com/files/f...ownload.aspx):

Default.aspx only has:

<asp:repeater ID="OuterRepeat er" runat="server">
<ItemTemplate >
Outer ItemDataBind function called <asp:Literal
ID="MyText" runat="server" /time(s)<br />

<asp:Repeater ID="InnerRepeat er" runat="server">
<ItemTemplate >
Nested ItemDataBind function called
<asp:Literal ID="Text" runat="server" /time(s)<br />

</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:repeater>

Default.aspx.cs contains:

protected override void OnInit(EventArg s e)
{
OuterRepeater.I temCreated += new
RepeaterItemEve ntHandler(Outer _ItemCreated);
OuterRepeater.I temDataBound += new
RepeaterItemEve ntHandler(Outer _ItemDataBound) ;
this.Load += new EventHandler(Pa ge_Load);
base.OnInit(e);
}

protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
List<stringmyLi st = new List<string>();
myList.Add("1") ;
OuterRepeater.D ataSource = myList;
OuterRepeater.D ataBind();
}
}

void Outer_ItemCreat ed(object sender, RepeaterItemEve ntArgs e)
{
Repeater repeater = (Repeater)e.Ite m.FindControl(" InnerRepeater") ;
if (repeater != null)
{
List<stringmyLi st = new List<string>();
myList.Add("1.1 ");
repeater.ItemDa taBound += new
RepeaterItemEve ntHandler(Inner _ItemDataBound) ;
repeater.DataSo urce = myList;
repeater.DataBi nd();
}
}

int outerCount = 0;

void Outer_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
outerCount++;
string myValue = (string)e.Item. DataItem;

Literal text = (Literal)e.Item .FindControl("M yText");
if (text != null)
{
text.Text = outerCount.ToSt ring();
}
}

int innerCount = 0;

void Inner_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
innerCount++;
string myValue = (string)e.Item. DataItem;
Literal text = (Literal)e.Item .FindControl("T ext");
text.Text = innerCount.ToSt ring();
}

So at this point, I'm just confused... is this a bug with asp.net? if so...
damn, it seems pretty major, imo. Any help would be appreciated...
Mar 15 '07 #1
4 4579
your are not checking the item type to see if its a Item or AlternateItem

-- bruce (sqlwork.com)

James Geurts wrote:
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). But... and this is the crappy
part, the nested repeater's events are fired twice. How do I know this? I
setup global private counter variables that get incremented on the repeater's
ItemDataBound event. The outer repeater is correct and only calls the
ItemDataBound event once for each item, but the inner nested repeater calls
it's ItemDataBound event twice for each item.

It's worth mentioning that I did set AutoEventWireup to false, just in case...

You can review the markup and code or download the code
(http://www.biasecurities.com/files/f...ownload.aspx):

Default.aspx only has:

<asp:repeater ID="OuterRepeat er" runat="server">
<ItemTemplate >
Outer ItemDataBind function called <asp:Literal
ID="MyText" runat="server" /time(s)<br />

<asp:Repeater ID="InnerRepeat er" runat="server">
<ItemTemplate >
Nested ItemDataBind function called
<asp:Literal ID="Text" runat="server" /time(s)<br />

</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:repeater>

Default.aspx.cs contains:

protected override void OnInit(EventArg s e)
{
OuterRepeater.I temCreated += new
RepeaterItemEve ntHandler(Outer _ItemCreated);
OuterRepeater.I temDataBound += new
RepeaterItemEve ntHandler(Outer _ItemDataBound) ;
this.Load += new EventHandler(Pa ge_Load);
base.OnInit(e);
}

protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
List<stringmyLi st = new List<string>();
myList.Add("1") ;
OuterRepeater.D ataSource = myList;
OuterRepeater.D ataBind();
}
}

void Outer_ItemCreat ed(object sender, RepeaterItemEve ntArgs e)
{
Repeater repeater = (Repeater)e.Ite m.FindControl(" InnerRepeater") ;
if (repeater != null)
{
List<stringmyLi st = new List<string>();
myList.Add("1.1 ");
repeater.ItemDa taBound += new
RepeaterItemEve ntHandler(Inner _ItemDataBound) ;
repeater.DataSo urce = myList;
repeater.DataBi nd();
}
}

int outerCount = 0;

void Outer_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
outerCount++;
string myValue = (string)e.Item. DataItem;

Literal text = (Literal)e.Item .FindControl("M yText");
if (text != null)
{
text.Text = outerCount.ToSt ring();
}
}

int innerCount = 0;

void Inner_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
innerCount++;
string myValue = (string)e.Item. DataItem;
Literal text = (Literal)e.Item .FindControl("T ext");
text.Text = innerCount.ToSt ring();
}

So at this point, I'm just confused... is this a bug with asp.net? if so...
damn, it seems pretty major, imo. Any help would be appreciated...
Mar 16 '07 #2
I don't see how that even applies to this situation. item events should only
be called once per item regardless of if it is an Item or AlternateItem.

Anyone from MS want to help with this?

Thanks

Jim

"bruce barker" wrote:
your are not checking the item type to see if its a Item or AlternateItem

-- bruce (sqlwork.com)

James Geurts wrote:
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). But... and this is the crappy
part, the nested repeater's events are fired twice. How do I know this? I
setup global private counter variables that get incremented on the repeater's
ItemDataBound event. The outer repeater is correct and only calls the
ItemDataBound event once for each item, but the inner nested repeater calls
it's ItemDataBound event twice for each item.

It's worth mentioning that I did set AutoEventWireup to false, just in case...

You can review the markup and code or download the code
(http://www.biasecurities.com/files/f...ownload.aspx):

Default.aspx only has:

<asp:repeater ID="OuterRepeat er" runat="server">
<ItemTemplate >
Outer ItemDataBind function called <asp:Literal
ID="MyText" runat="server" /time(s)<br />

<asp:Repeater ID="InnerRepeat er" runat="server">
<ItemTemplate >
Nested ItemDataBind function called
<asp:Literal ID="Text" runat="server" /time(s)<br />

</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:repeater>

Default.aspx.cs contains:

protected override void OnInit(EventArg s e)
{
OuterRepeater.I temCreated += new
RepeaterItemEve ntHandler(Outer _ItemCreated);
OuterRepeater.I temDataBound += new
RepeaterItemEve ntHandler(Outer _ItemDataBound) ;
this.Load += new EventHandler(Pa ge_Load);
base.OnInit(e);
}

protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
List<stringmyLi st = new List<string>();
myList.Add("1") ;
OuterRepeater.D ataSource = myList;
OuterRepeater.D ataBind();
}
}

void Outer_ItemCreat ed(object sender, RepeaterItemEve ntArgs e)
{
Repeater repeater = (Repeater)e.Ite m.FindControl(" InnerRepeater") ;
if (repeater != null)
{
List<stringmyLi st = new List<string>();
myList.Add("1.1 ");
repeater.ItemDa taBound += new
RepeaterItemEve ntHandler(Inner _ItemDataBound) ;
repeater.DataSo urce = myList;
repeater.DataBi nd();
}
}

int outerCount = 0;

void Outer_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
outerCount++;
string myValue = (string)e.Item. DataItem;

Literal text = (Literal)e.Item .FindControl("M yText");
if (text != null)
{
text.Text = outerCount.ToSt ring();
}
}

int innerCount = 0;

void Inner_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
innerCount++;
string myValue = (string)e.Item. DataItem;
Literal text = (Literal)e.Item .FindControl("T ext");
text.Text = innerCount.ToSt ring();
}

So at this point, I'm just confused... is this a bug with asp.net? if so...
damn, it seems pretty major, imo. Any help would be appreciated...
Mar 16 '07 #3
Hello? Anyone have an answer for this?

"James Geurts" wrote:
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). But... and this is the crappy
part, the nested repeater's events are fired twice. How do I know this? I
setup global private counter variables that get incremented on the repeater's
ItemDataBound event. The outer repeater is correct and only calls the
ItemDataBound event once for each item, but the inner nested repeater calls
it's ItemDataBound event twice for each item.

It's worth mentioning that I did set AutoEventWireup to false, just in case...

You can review the markup and code or download the code
(http://www.biasecurities.com/files/f...ownload.aspx):

Default.aspx only has:

<asp:repeater ID="OuterRepeat er" runat="server">
<ItemTemplate >
Outer ItemDataBind function called <asp:Literal
ID="MyText" runat="server" /time(s)<br />

<asp:Repeater ID="InnerRepeat er" runat="server">
<ItemTemplate >
Nested ItemDataBind function called
<asp:Literal ID="Text" runat="server" /time(s)<br />

</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:repeater>

Default.aspx.cs contains:

protected override void OnInit(EventArg s e)
{
OuterRepeater.I temCreated += new
RepeaterItemEve ntHandler(Outer _ItemCreated);
OuterRepeater.I temDataBound += new
RepeaterItemEve ntHandler(Outer _ItemDataBound) ;
this.Load += new EventHandler(Pa ge_Load);
base.OnInit(e);
}

protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
List<stringmyLi st = new List<string>();
myList.Add("1") ;
OuterRepeater.D ataSource = myList;
OuterRepeater.D ataBind();
}
}

void Outer_ItemCreat ed(object sender, RepeaterItemEve ntArgs e)
{
Repeater repeater = (Repeater)e.Ite m.FindControl(" InnerRepeater") ;
if (repeater != null)
{
List<stringmyLi st = new List<string>();
myList.Add("1.1 ");
repeater.ItemDa taBound += new
RepeaterItemEve ntHandler(Inner _ItemDataBound) ;
repeater.DataSo urce = myList;
repeater.DataBi nd();
}
}

int outerCount = 0;

void Outer_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
outerCount++;
string myValue = (string)e.Item. DataItem;

Literal text = (Literal)e.Item .FindControl("M yText");
if (text != null)
{
text.Text = outerCount.ToSt ring();
}
}

int innerCount = 0;

void Inner_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
innerCount++;
string myValue = (string)e.Item. DataItem;
Literal text = (Literal)e.Item .FindControl("T ext");
text.Text = innerCount.ToSt ring();
}

So at this point, I'm just confused... is this a bug with asp.net? if so...
damn, it seems pretty major, imo. Any help would be appreciated...
Mar 24 '07 #4
Got a reply from Microsoft:

"The repeater calls databind on all its item children in the ItemDataBound
event. So the inner repeater is databound once by the outer databound, and
once by you in your Outer_ItemCreat ed event handler. To make the inner
repeater bind just once, remove the call to DataBind in Outer_ItemCreat ed."

Hope that helps someone...
"James Geurts" wrote:
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). But... and this is the crappy
part, the nested repeater's events are fired twice. How do I know this? I
setup global private counter variables that get incremented on the repeater's
ItemDataBound event. The outer repeater is correct and only calls the
ItemDataBound event once for each item, but the inner nested repeater calls
it's ItemDataBound event twice for each item.

It's worth mentioning that I did set AutoEventWireup to false, just in case...

You can review the markup and code or download the code
(http://www.biasecurities.com/files/f...ownload.aspx):

Default.aspx only has:

<asp:repeater ID="OuterRepeat er" runat="server">
<ItemTemplate >
Outer ItemDataBind function called <asp:Literal
ID="MyText" runat="server" /time(s)<br />

<asp:Repeater ID="InnerRepeat er" runat="server">
<ItemTemplate >
Nested ItemDataBind function called
<asp:Literal ID="Text" runat="server" /time(s)<br />

</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:repeater>

Default.aspx.cs contains:

protected override void OnInit(EventArg s e)
{
OuterRepeater.I temCreated += new
RepeaterItemEve ntHandler(Outer _ItemCreated);
OuterRepeater.I temDataBound += new
RepeaterItemEve ntHandler(Outer _ItemDataBound) ;
this.Load += new EventHandler(Pa ge_Load);
base.OnInit(e);
}

protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
List<stringmyLi st = new List<string>();
myList.Add("1") ;
OuterRepeater.D ataSource = myList;
OuterRepeater.D ataBind();
}
}

void Outer_ItemCreat ed(object sender, RepeaterItemEve ntArgs e)
{
Repeater repeater = (Repeater)e.Ite m.FindControl(" InnerRepeater") ;
if (repeater != null)
{
List<stringmyLi st = new List<string>();
myList.Add("1.1 ");
repeater.ItemDa taBound += new
RepeaterItemEve ntHandler(Inner _ItemDataBound) ;
repeater.DataSo urce = myList;
repeater.DataBi nd();
}
}

int outerCount = 0;

void Outer_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
outerCount++;
string myValue = (string)e.Item. DataItem;

Literal text = (Literal)e.Item .FindControl("M yText");
if (text != null)
{
text.Text = outerCount.ToSt ring();
}
}

int innerCount = 0;

void Inner_ItemDataB ound(object sender, RepeaterItemEve ntArgs e)
{
innerCount++;
string myValue = (string)e.Item. DataItem;
Literal text = (Literal)e.Item .FindControl("T ext");
text.Text = innerCount.ToSt ring();
}

So at this point, I'm just confused... is this a bug with asp.net? if so...
damn, it seems pretty major, imo. Any help would be appreciated...
Mar 28 '07 #5

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

Similar topics

3
14732
by: DonRex | last post by:
Hello all! I couldn't find a web application-newsgroup for ASP.NET, so I'm sorry if this is the wrong forum! Synopsis: In my webform I have 3 nested repeaters: rpWeeks ----- rpTime
0
1542
by: Machi | last post by:
let say in parent-child scenerio (Product: Product Category - one product category may has many products), i am using nested repeaters where parent repeater will be used to display info and child repeater will be used to display info, i define the parent and child repeaters once in HTML tag, and create the repeaters for different categories and products repeaters (instances of Repeater) dynamically in Code-Behind using C#, however, when i view...
2
1761
by: Matt Jensen | last post by:
Howdy I have 2 repeaters on a C# page, 1 nested under the other. In some cases, the nested repeaters <ItemTemplate> does not contain rows - how does one display a text message in place of the empty rows eg. "No events for this month"? Thanks Matt
1
10833
by: jeremystein | last post by:
With nested repeaters, how can I access the outer repeater's DataItem from the inner repeater? Here's a snippet from my aspx: <asp:repeater id="OuterRepeater" runat="server" onItemDataBound="PrepareInner"> <ItemTemplate> <h1> <%# DataBinder.Eval(Container.DataItem, "number") %>
6
1765
by: Steve Hershoff | last post by:
Hi everyone, I've got a strange one here. There are two datagrids on my page, one nested within the other. I'll refer to them as the topmost and secondary datagrids. In the topmost datagrid's OnItemDataBound() method we check for the row in which it's appropriate to add the secondary datagrid. Exactly one row in the topmost grid will contain the secondary grid.
0
1763
by: Adam Knight | last post by:
Hi All, I have a repeater control nested inside another repeater control. The nested (child) repeater control, is bound to an object data source. My problem is, i need to send a data item value from the 'item' of parent control as a parameter to the object datasource of the child repeater control. Any thoughts on how to best do this? Declaritively?
2
4954
by: Josh | last post by:
I have a nested repeater situation with a Link Button on the nested repeater. However when the link button is clicked I get a postback but the event never takes place. I'm trying to wire up the nested repeaters ItemCommand event in the ItemDataBound of the outer repeater. I have even tried sharing the Outer repeaters ItemCommand event but it still does not fire. I'm missing a trick here, can you tell me what it is?
1
4338
PrinsonG
by: PrinsonG | last post by:
My Query is How do I export to excel/csv using Nested Repeaters. My project is web-based and i am using C#.Net. In this i use three repeaters. one displays ID, Name of the user. second displays break details. third displays total time spent.
3
9471
by: Leon Mayne | last post by:
If I have a datatable which looks like this: Record Id, Group Id, Name 1, 1, Test 1 2, 1, Test 2 3, 2, Test 3 4, 3, Test 4 Is it possible to use nested repeaters to group the information by GroupId? e.g. displaying something like
0
9901
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9751
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10758
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9513
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5743
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4562
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3187
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.