title: Working with Asp.Net ListView and Asp.Net Ajax Update Panel
body: <p>Hello there, I hope this will be easy for someone to answer. First off I was trying to make a <code>ListView</code> bound to a <code>DataPager</code> and put in an ASP.NET <code>UpdatePanel</code> to make an AJAX-powered pager for the records from my database. I grabbed an <code>UpdatePanel</code> and I placed:</p>
  
  <ol>
  <li><code>SqlDataSource</code></li>
  <li><code>ListView</code> - having <code>ItemTemplate</code> including one <code>ImageButton</code> and several other ASP.NET controls in it</li>
  <li><code>DataPager</code></li>
  </ol>
  
  <p>in the <code>ContentTemplate</code>. Assigning the <code>DataPager</code> ID to the <code>AsyncPostbackTrigger</code> in the <code>UpdatePanel</code>'s trigger fields worked perfectly. </p>
  
  <p>I also wanted to perform a full post-back in the <code>ImageButton</code> <code>Click</code> event. However, because the <code>ImageButton</code> is inside the <code>ListView</code>,  the <code>UpdataPanel</code> causes a partial post-back. I tried adding the ImageButton as an <code>UpdatePanel</code> <code>PostBackTrigger</code>, but the <code>UpdatePanel</code> demands a control ID, and won't accept the <code>ImageButton</code> since it is inside the <code>ListView</code>. </p>
  
  <p>How do I pass it a control ID for an element inside <code>ItemTemplate</code> of the <code>ListView</code> and successfully cause a full post back?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;&lt;/asp:ScriptManager&gt;
  &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"&gt;
      &lt;ContentTemplate&gt; 
          &lt;asp:SqlDataSource ... &gt;&lt;/asp:SqlDataSource&gt;
          &lt;asp:ListView ID="ListViewForAlbums" runat="server" &gt;
              &lt;ItemTemplate&gt;
                  &lt;div class="album"&gt;
                      &lt;asp:ImageButton ID="albumPhoto" class="albumPhotosStyle" runat="server" ImageUrl="&lt;%# Bind('albumPhotoPath') %&gt;" AlternateText="&lt;%# Bind('album_id') %&gt;" ToolTip="&lt;%# Bind('albumDetails') %&gt;" onclick="albumPhotos_Click"  /&gt;
                      &lt;div class="albumInfoHolder"&gt;
  
                      ...
  
                      &lt;/div&gt;
                  &lt;/div&gt; &lt;!-- End Album --&gt;
              &lt;/ItemTemplate&gt;
              &lt;EmptyDataTemplate&gt;
                  &lt;p&gt;No Albums Yet. Check Back Soon!&lt;/p&gt;
              &lt;/EmptyDataTemplate&gt;
          &lt;/asp:ListView&gt;
  
          &lt;asp:DataPager ID="DataPagerForAlbums" runat="server" PagedControlID="ListViewForAlbums" PageSize="3" &gt;
              &lt;Fields&gt;
                  &lt;asp:NextPreviousPagerField ShowFirstPageButton="True" FirstPageText="&amp;laquo" ShowNextPageButton="False"  ShowPreviousPageButton="false" /&gt;
                  &lt;asp:NumericPagerField /&gt;
                  &lt;asp:NextPreviousPagerField ShowLastPageButton="True" LastPageText="&amp;raquo" ShowPreviousPageButton="False"  ShowNextPageButton="false" /&gt;
              &lt;/Fields&gt;
          &lt;/asp:DataPager&gt;
          &lt;/p&gt;
      &lt;/ContentTemplate&gt;
      &lt;Triggers&gt;
          &lt;asp:AsyncPostBackTrigger ControlID="DataPagerForAlbums" /&gt;
      &lt;/Triggers&gt;
  &lt;/asp:UpdatePanel&gt; 
  </code></pre>