title: Components in AJAX tab not showing up when switching tab
body: <p>I am trying to hide and show AJAX tab panel with certain condition which I get from SQL. Let's say I got three tab, the first tab always there, the second tab showing only when it is not yet delivered whereas third tab showing only when it is delivered. Here is the method which I switch tab to get the tab index:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          //Get distributionID based on URL
          distributionID = Request.QueryString["id"];
  
          //First tab to display beneficiary details
          beneficiaryIndv = packBLL.getBeneficiaryDetail(distributionID);
  
          if (IsPostBack)
          {
              //Get the index of selected tab
              if (!(ViewState["TabIndex"] == null) &amp;&amp; (!(sender == null)))
              {
                  if (sender.GetType().ToString().Equals("AjaxControlToolkit.TabContainer"))
                  {
                      ((AjaxControlToolkit.TabContainer)sender).ActiveTabIndex = (int)ViewState["TabIndex"];
                  }
              }
          }
  
          //On page load to check the delivery status to determine which tab to hide
          string isDelivered = packBLL.checkIsDelivered(distributionID);
          if (isDelivered == "Y")
          {
              TabPanelSPU.Visible = false;
          }
          else
          {
              TabPanelViewSPUItem.Visible = false;
          }
      }
  
  protected void TabContainer_OnActiveTabChanged(object sender, EventArgs e)
      {
          ViewState["TabIndex"] = TabContainer.ActiveTabIndex;
  
          if ((int)ViewState["TabIndex"] == 1)
          {
              //Get the list of standard packing unit by distribution
              List&lt;DistributionStandardPackingUnits&gt; SPUList = new List&lt;DistributionStandardPackingUnits&gt;();
              SPUList = packBLL.getAllDistSPUByDistID(distributionID);
              gvSPU1.DataSource = SPUList;
              gvSPU1.DataBind();
          }
          else if ((int)ViewState["TabIndex"] == 2)
          {
              //Get the list of standard packing unit by distribution
              List&lt;DistributionStandardPackingUnits&gt; SPUList = new List&lt;DistributionStandardPackingUnits&gt;();
              SPUList = packBLL.getAllDistSPUByDistID(distributionID);
              gvSPU.DataSource = SPUList;
              gvSPU.DataBind();
          }
      }
  </code></pre>
  
  <p>However, when the delivery status is delivered, it hides the second tab. But the components inside third tab is not showing. I wonder is it because of the if else statement in tab on active change method causing this problem?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>&lt;asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt;
                          &lt;/asp:ToolkitScriptManager&gt;
  
                          &lt;asp:TabContainer ID="TabContainer" runat="server" ActiveTabIndex="0"
                              OnActiveTabChanged="TabContainer_OnActiveTabChanged" AutoPostBack="true"&gt;
  
                              &lt;!--FIRST TAB --&gt;
                              &lt;asp:TabPanel ID="TabPanelBeneficiary" runat="server" HeaderText="Beneficiary" CssClass="ajax__tab_tab"&gt;
                                  &lt;ContentTemplate&gt;
                                      &lt;h3 class="form-section"&gt;Person Info&lt;/h3&gt;
  
                                      &lt;h3 class="form-section"&gt;Address&lt;/h3&gt;
  
                                  &lt;/ContentTemplate&gt;
                              &lt;/asp:TabPanel&gt;
  
                              &lt;!--SECOND TAB --&gt;
                              &lt;asp:TabPanel ID="TabPanelSPU" runat="server" HeaderText="Standard Packing" CssClass="ajax__tab_tab"&gt;
                                  &lt;ContentTemplate&gt;
  
                                   &lt;/ContentTemplate&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                                                          &lt;/ContentTemplate&gt;
                              &lt;/asp:TabPanel&gt;
  
                              &lt;!--THIRD TAB --&gt;
                              &lt;asp:TabPanel ID="TabPanelViewSPUItem" runat="server" HeaderText="Distributed Packing Items" CssClass="ajax__tab_tab"&gt;
                                  &lt;ContentTemplate&gt;
  
                                  &lt;/ContentTemplate&gt;
                              &lt;/asp:TabPanel&gt;
  </code></pre>