I have a repeater i want to use to list every node name within a hidden field. i want to then extract that value in the code behind during databound. For some reason that last node in the list will not appear.
items before being repeated: shop1shop2shop3shop4shop5 shop6shop7shop8shop9shop10shop11 | Items after repeated: shop1,shop1,shop2,shop1,shop2,shop3,shop1,shop2,shop3,shop4,shop1,shop2,shop3,shop4,shop5,shop1,shop2,shop3,shop4,shop5, shop6,shop1,shop2,shop3,shop4,shop5, shop6,shop7,shop1,shop2,shop3,shop4,shop5, shop6,shop7,shop8,shop1,shop2,shop3,shop4,shop5, shop6,shop7,shop8,shop9,shop1,shop2,shop3,shop4,shop5, shop6,shop7,shop8,shop9,shop10,
As you can see shop 11 does not show after the data has been bound.
Any ideas? its like the a limit on how many items i can have in the repeater. Ive tried moving shop11 higher up but this just meant shop 10 disappeared.
Do you actually need to get the value at each item binding? Otherwize you could catch the global "Bound" event of the repeater at the end, and get everything at once.
My guess is that in the Item_Bound method, the item has been bound, but not added to the repeater itedm list yet. This would mean that in fact, the first time you get into the event, there is nothing in the list. So, your first entry "shop1", would actually be displayed in the second loop, etc.
This is just a guess since I can't make any test for the moment, but you could easily find out if it is the case by displaying some text before entering your loop. That way you can see if the first time you get some text out of the loop or not.
I never really solved this one. i just created a dud node that was last in the list. Seeing as the last node never gets read it meant that store11 now shows.
Repeater not listing last node in list
I have a repeater i want to use to list every node name within a hidden field. i want to then extract that value in the code behind during databound. For some reason that last node in the list will not appear.
<asp:Repeater ID="rptStockists" runat="server" OnItemDataBound="rowRepeater_ItemBound">
<ItemTemplate>
<asp:HiddenField ID="HdName" runat="server" Value='<%#((Node)Container.DataItem).Name%>' />
</ItemTemplate>
</asp:Repeater>
public void DisplayAll()
{
Response.Write("items before being repeated: ");
foreach (Node child in n.Children)
{
nodes.Add(child);
Response.Write(child.Name);
}
Response.Write(" | Items after repeated: ");
rptStockists.DataSource = nodes;
rptStockists.DataBind();
}
protected void rowRepeater_ItemBound(object sender, RepeaterItemEventArgs e)
{
foreach (RepeaterItem item in rptStockists.Items)
{
HiddenField hiddenName = (HiddenField)item.FindControl("HdName");
Response.Write(hiddenName.Value+",");
}
}
items before being repeated: shop1shop2shop3shop4shop5 shop6shop7shop8shop9shop10shop11 | Items after repeated: shop1,shop1,shop2,shop1,shop2,shop3,shop1,shop2,shop3,shop4,shop1,shop2,shop3,shop4,shop5,shop1,shop2,shop3,shop4,shop5, shop6,shop1,shop2,shop3,shop4,shop5, shop6,shop7,shop1,shop2,shop3,shop4,shop5, shop6,shop7,shop8,shop1,shop2,shop3,shop4,shop5, shop6,shop7,shop8,shop9,shop1,shop2,shop3,shop4,shop5, shop6,shop7,shop8,shop9,shop10,
As you can see shop 11 does not show after the data has been bound.
Any ideas? its like the a limit on how many items i can have in the repeater. Ive tried moving shop11 higher up but this just meant shop 10 disappeared.
Hi Phil,
Do you actually need to get the value at each item binding? Otherwize you could catch the global "Bound" event of the repeater at the end, and get everything at once.
My guess is that in the Item_Bound method, the item has been bound, but not added to the repeater itedm list yet. This would mean that in fact, the first time you get into the event, there is nothing in the list. So, your first entry "shop1", would actually be displayed in the second loop, etc.
This is just a guess since I can't make any test for the moment, but you could easily find out if it is the case by displaying some text before entering your loop. That way you can see if the first time you get some text out of the loop or not.
So, for example:
Hope this helps.
Cheers,
Michael
Thanks mike. The response.write before entering the loop confirmed that store10 was the last in the loop. I dont get what has happened to the store11.
I never really solved this one. i just created a dud node that was last in the list. Seeing as the last node never gets read it meant that store11 now shows.
is working on a reply...