Hi guys,
I Have WebExplorerBar and inside I have ItemTemplate and inside ItemTemplate I have usercontrol.In code behind I try to access to it bu unsuccesfull.
<ig:WebExplorerBar ID="WebExplorerBar1" runat="server" CssClass="viewPanel" StyleSetName="Header" Width="805px" Height="870px"> <%--<igmisc:WebPanel ID="ViewPanel" runat="server" CssClass="viewPanel" StyleSetName="Header" Width="805px" Height="870px">--%> <%--<ClientSideEvents ExpandedStateChanging="CancelXpand" />--%> <ItemTemplate> <div class="content" id="content"> <div id="navigation" class="navigation" style="height: 5px;"> </div> <div id="findemp" class="findemp" style="margin-top: 0px"> <div id="personInfo" style="margin-top: 0px"> <table> <tr> <td> <uc1:CFNList ID="CFNList1" runat="server"></uc1:CFNList> </td>
Here is my coding in C#:
UserControl cntrl = (UserControl)this.WebExplorerBar1.Groups[0].FindControl("CFNList1").Controls[0];
and when I am running I am getting runtime error:
it is pointing to Groups[0] and say:Index was out of range.
Please help.
Thanks,
Hello Jane,
I suggest you should use
UserControl cntrl = (UserControl)this.WebExplorerBar1.Groups[0].FindControl("CFNList1") to access the user control.
I am not aware what the exact issue you are experiencing is, as there is no code available for debugging shared in the topic. However, in order to better assist you I have created a code sample illustrating how to access a user control contained in ItemTemplate. The sample also illustrates how to access other controls in Item Template as well.
PS: As Version=15.1.20151.1018 is used to create the sample, in order to run it could require for to change the references if using different version.
Please let me know how my suggestions work for you.
Hello,
I used exactly what you are suggested:
UserControl cntrl = (UserControl)this.WebExplorerBar1.Groups[0].FindControl("CFNList1");
But received runtime error:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Thanks for your help