title: InvalidOperationException: PostBack Trigger Cannot Find a Control within the ItemTemplate of a DataList
body: <p>I would like to trigger a PostBack when the asp:LinkButton "addToCartButton" is clicked (see code below).</p>
  
  <p>I have declared a PostBack Trigger with the asp:UpdatePanel "updPnlProductsList" (see code below).</p>
  
  <pre><code>&lt;asp:Panel ID="pnlProductsList" runat="server" Visible="false"&gt;
  &lt;asp:UpdatePanel ID="updPnlProductsList" runat="server" UpdateMode="Conditional"&gt;
  &lt;ContentTemplate&gt;
      &lt;div class="featured"&gt;
          &lt;h3&gt;Product listing&lt;/h3&gt;
          &lt;div class="product clearfix"&gt;
              &lt;asp:DataList ID="productsList" runat="server" DataKeyField="prodid" OnItemCommand="productsList_ItemCommand"
                  OnItemDataBound="productsList_ItemDataBound"&gt;
                  &lt;HeaderTemplate&gt;
                      &lt;table&gt;
                          &lt;col width="85" /&gt;
                          &lt;col width="315" /&gt;
                          &lt;col width="85" /&gt;
                          &lt;col width="315" /&gt;
                          &lt;col width="85" /&gt;
                          &lt;tr&gt;
                              &lt;th align="left"&gt;
                                  &amp;nbsp;
                              &lt;/th&gt;
                              &lt;th align="left"&gt;
                                  Product Description
                              &lt;/th&gt;
                              &lt;th align="center"&gt;
                                  In Stock
                              &lt;/th&gt;
                              &lt;th align="center"&gt;
                                  Price
                              &lt;/th&gt;
                              &lt;th align="left"&gt;
                                  &amp;nbsp;
                              &lt;/th&gt;
                          &lt;/tr&gt;
                  &lt;/HeaderTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;tr&gt;
                          &lt;td height="85" valign="top"&gt;
                              &lt;asp:HyperLink ID="standardImage" Style="float: left; margin-right: 5px; border: 2px;
                                  vertical-align: top;" Width="75" Height="75" runat="server"&gt;&lt;/asp:HyperLink&gt;
                          &lt;/td&gt;
                          &lt;td height="85" valign="top"&gt;
                              &lt;asp:LinkButton ID="lbProductDescription" CommandName="show_product" runat="server" /&gt;
                              &lt;p&gt;
                                  &lt;asp:Label ID="MfPartNo" runat="server" /&gt;&lt;/p&gt;
                          &lt;/td&gt;
                          &lt;td height="85" align="center" valign="top"&gt;
                              &lt;p&gt;
                                  &lt;asp:Label ID="inventoryTextLabel" runat="server" /&gt;&lt;/p&gt;
                          &lt;/td&gt;
                          &lt;td style="padding-bottom: 10px;" height="85" align="center" valign="top"&gt;
                              &lt;div class="product-actions clearfix"&gt;
                                  &lt;p class="price"&gt;
                                      &lt;strong&gt;
                                          &lt;asp:Label ID="sellPriceLabel" runat="server" Style="font-size: 0.9em;" /&gt;&lt;/strong&gt;
                                  &lt;/p&gt;
                              &lt;/div&gt;
                          &lt;/td&gt;
                          &lt;td style="padding-bottom: 10px;" height="85" valign="top"&gt;
                              &lt;div class="product-actions clearfix"&gt;
                                  &lt;p class="view"&gt;
                                      &lt;asp:LinkButton ID="addToCartButton" runat="server" Text="&lt;span&gt;&lt;strong&gt;Buy&lt;/strong&gt;&lt;/span&gt;"
                                          CommandName="add_to_cart" class="newactionbutton" /&gt;
                                  &lt;/p&gt;
                              &lt;/div&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;/div&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;SeparatorTemplate&gt;
                      &lt;tr&gt;
                          &lt;td colspan="5" style="border-bottom: dotted 1px gray; line-height: 0.1em;"&gt;
                              &amp;nbsp;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/SeparatorTemplate&gt;
                  &lt;FooterTemplate&gt;
                      &lt;/table&gt;
                  &lt;/FooterTemplate&gt;
              &lt;/asp:DataList&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/ContentTemplate&gt;
  &lt;Triggers&gt;
      &lt;asp:PostBackTrigger ControlID="addToCartButton" /&gt;
  &lt;/Triggers&gt;
  &lt;/asp:UpdatePanel&gt;
  &lt;/asp:Panel&gt;
  &lt;!-- /The all new Products List. --&gt;
  </code></pre>
  
  <p>Unfortunately, when I run this code I get the error:</p>
  
  <p>InvalidOperationException: A control with ID 'addToCartButton' could not be found for the trigger in UpdatePanel 'updPnlProductsList'.</p>
  
  <p>Would someone please help me reference the 'addToCartButton' within the ItemTemplate of the DataList.</p>
  
  <p>Or maybe I can cause a PostBack in the asp:LinkButton code behind?  I'm coding in C#.</p>
  
  <p>Kind Regards</p>
  
  <p>Walter</p>