0
votes

I have a nested repeater and i want to pass value in its header. Here is my code so far.. The main problem is the id of the control in header template is also coming from code behind.

<asp:Repeater ID="RptrProgCategory" runat="server">
    <ItemTemplate>
        <asp:Repeater ID="RptrPrograms" runat="server">
            <HeaderTemplate><input type="hidden" id="<%= questvalue%>"/></HeaderTemplate>
            <ItemTemplate>                      
                <a href="/" id="catid" class="off"><%# DataBinder.Eval(Container.DataItem, "cat") %></a>
            </ItemTemplate>
        </asp:Repeater>
    </ItemTemplate>
</asp:Repeater>

I want value in questvalue from code behind. Any idea how to achieve this?

Edit: I wanted to put this value in a DataTable and bind that value in Repeater bcoz i want output like this may be <%# DataBinder.Eval(Container.DataItem, "questvalue") %> instead of <%= questvalue%>..but in tht case i am not able to find the control

Category1(id of hidden field )
  subcat1
  subcat2
  subcat3
Category2(id of hidden field)
  subcat4
  subcat5..and so on..
2
What's the point of a hidden field if you don't know the id? Are you sure you don't want the value to be dynamic? - Mark Brackett
actually there is some javascript connected to ID...and i can't change the javascript...so i am putting hidden field with ID from code behind to make that happen. - AB.

2 Answers

0
votes
Repeater mainRepeater = this.Page.FindControl("RptrProgCategory") as Repeater;
Repeater nestedRepeater = mainRepeater.FindControl("RptrProgCategory") as Repeater;

You can then do a FindControl in nestedRepeater for questValue. Add a runat='server' to questvalue so that you can access it in code behind.

I am writing this from memory, syntax might not be correct but it should get you off in the right direction.

0
votes

set the id of the control in the repeater to something like mycontrolId - and then on OnItemDataBound - (or even OnItemCreated) use findcontrol("mycontrolId") - and then change the id of the control to your questvalue param.