I am using repeater:
<asp:Repeater ID="rptCategories" runat="server" OnItemDataBound="RptCategories_ItemDataBound">
<ItemTemplate>
<asp:Panel CssClass="category-wrapper" ID="pnlCategory" runat="server">
<%# Eval("SponsorshipCategoryName") %>
<asp:HiddenField runat="server" ID="hdnCategoryID" Value='<%# Eval("SponsorshipCategoryID") %>' />
</asp:Panel>
</ItemTemplate>
</asp:Repeater>
Depening on my category type I add RadionButtonList or list of check boxes to panel in my code behind.
I set id:
rblItems.ID = "rbl_" + category.SponsorshipCategoryID;
and then put control in panel:
panel.Controls.Add(rblItems);
Now I nead to be able to loop though all category panels and get those radio button lists or checkboxes.
For this I loop though rptCategories.Items
foreach (RepeaterItem rptItem in rptCategories.Items)
{
var hdnCategoryID = rptItem.FindControl(HdnCategoryID_ID) as
HiddenField;
var pnlCategory = rptItem.FindControl(PnlCategory_ID) as Panel;
var categoryID = (hdnCategoryID == null || hdnCategoryID.Value ==
string.Empty) ? 0 : int.Parse(hdnCategoryID.Value);
}
It finds hidden field and panel just fine. But when I am trying to find control inside my panel with ID I am interested in it returns null.
var control = pnlCategory.FindControl("rbl_" + categoryToUpdate.SponsorshipCategoryID);
I can't use item databound event here. Any ideas what the issues can be?