nested repeater
-
I am working with nested repeater and i have 3 repeaters nested one under the other the one nested under the master, can be manipulated through a normal _OnItemDataBound event, but to reach the repeaters underneath the second level is not working i tried to add this: private void rptStockCategories_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ((Repeater)e.Item.FindControl("rptStockCategories2")).ItemDataBound += new RepeaterItemEventHandler(rptStockCategories3_OnItemDataBound); but i think it only add the event, but wont runn it any suggestions? any
-
I am working with nested repeater and i have 3 repeaters nested one under the other the one nested under the master, can be manipulated through a normal _OnItemDataBound event, but to reach the repeaters underneath the second level is not working i tried to add this: private void rptStockCategories_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ((Repeater)e.Item.FindControl("rptStockCategories2")).ItemDataBound += new RepeaterItemEventHandler(rptStockCategories3_OnItemDataBound); but i think it only add the event, but wont runn it any suggestions? any
Hi You need not attach event handler at run time for inner controls. You can do it design time If you are using C#, then Repeater's ItemDataBound event will be as
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//Repeater 1 gets fired
}Make sure that in the HTML code has 'OnItemDataBound' and set it as 'Repeater1_ItemDataBound' Now for inner repeater, copy the above code for Repeater1's event and rename it to second repeater. So second repeater event will be like this.
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//Repeater 2 gets fired
}and in your HTML code will be as 'OnItemDataBound' and set it as 'Repeater1_ItemDataBound' Repeat the same for next inner repeater. So, inner controls' events automatically gets fired. :)
Harini