0

I have an aspx page in which I have Ajax UpdatePanel which has a AJAX Tabcontainer which has 5 tab. In First tab I have a DropDownList for ProductID. In the second tab I have used a UserControl whose parameter needs to be reflected based on productID. I want to Access the DropDownList ProductID in the user control which I am not getting. Part of my code is

DropDownList IDList = (DropDownList)(this.Parent.FindControl("ProductID");

this is not working and I am getting NULL. I also have Tried

DropDownList IDList = (DropDownList)(this.Page.FindControl("ProductID");

Please tell me how I can do this.

As asked Part of necessary code is

<asp:UpdatePanel ID="UpdatePanelTankFormula" runat="server">
    <ContentTemplate>
        <asp:tabcontainer id="TabContainerTankFormula" AutoPostBack="true" runat="server" OnClientActiveTabChanged="clientActiveTabChanged"   activetabindex="0" style="width:100%;">  

           <asp:TabPanel ID="InputDataTab" runat="server"  HeaderText="Data Input">
               <ContentTemplate> 
                   <asp:DropDownList id="TankNameCombo" DataTextField="TankName" runat="server" AutoPostBack="true" DataValueField="customertankid"   width="200px" onclick="javascript:SetHiddenField();">    </asp:DropDownList>
               </ContentTemplate> 
           </asp:TabPanel>

           <asp:TabPanel ID="LacticAcidAdditionTab" runat="server"  HeaderText="Lactic Acid Addition">
               <ContentTemplate> 
                   //My user control
                   <UC:TankNote runat="server" ID="LaticTankNotesUC" GetNoteType="LAC" MEQMode="False"></UC:TankNote> 
               </ContentTemplate> 
           </asp:TabPanel>

        </asp:tabcontainer>
    <ContentTemplate>
</asp:UpdatePanel>

Now in the Code Behind of this User Control I want to access this DropDownList, which I am not getting. For the fix I have define a Public function that return the value of this list. But its a fix not solution.

Rohit Rohela
  • 422
  • 6
  • 21

1 Answers1

0

You will have something like this in tab control.

 <cc1:TabContainer ID="TabContainer1" runat="server">
    <cc1:TabPanel ID="TabPanel1" runat="server">
        <ContentTemplate>
            <asp:DropDownList id="dropdownlist1" runat="Server"/>
        </ContentTemplate>
    </cc1:TabPanel>

So first you need to find tabPanel1 then find dropdownlist1 like following.

TabContainer TabContainer1= (TabContainer)(this.Page.FindControl("TabContainer1");
if (TabContainer1!=null){
TabPanel TabPanel1= (TabPanel)(this.TabContainer1.FindControl("TabPanel1");
if(TabPanel1 !=null){
DropDownList dropdownlist1= (DropDownList)(this.TabPanel1.FindControl("dropdownlist1");

}}
Jalpesh Vadgama
  • 13,653
  • 19
  • 72
  • 94