title: How to use datapager with Repeater
body: <p>I have a Repeater control and inside my Repeater control I have many controls like gridview, detailsview and some other controls. But now my page become cluttered with controls as it repeats. What I want to achieve is to add the datapager to my page so that you can page through all the data in my controls. for example the first page would contain all items in my repeater with some data, second page all items with different data.</p>
  
  <p>Here is my Repeater control:</p>
  
  <pre><code>&lt;asp:Repeater ID="Repeater1" runat="server"  DataSourceID="SchemeDataSource1"&gt;
   &lt;ItemTemplate&gt;
      &lt;table style="border: thin solid #000000"; width: "100%" &gt;
        &lt;tr&gt;
          &lt;td&gt;PRENO
             &lt;asp:Label ID="lblPreno" runat="server" Text='&lt;%# Bind("PRENR") %&gt;'&gt;&lt;/asp:Label&gt;
              MONTHLY PREMIUM
              &lt;asp:Label ID="lblPrem" runat="server" Text='&lt;%# Bind("PREMIUM") %&gt;'&gt;&lt;/asp:Label&gt;
          &lt;br /&gt;
          &lt;/td&gt;
          &lt;td align="right"&gt;
           &lt;asp:LinkButton ID="lnkPre" runat="server" 
           ToolTip="Copy Premium To New Scheme" Font-Bold="True" Font-Size="Larger" Visible="true"&gt;&gt;&gt;&lt;/asp:LinkButton&gt;
          &lt;/td&gt;
         &lt;/tr&gt;
  
         &lt;tr&gt;
          &lt;td&gt;Relation: [
           &lt;asp:Label ID="lblRel" runat="server" Text='&lt;%# Bind("RELATION") %&gt;'&gt;&lt;/asp:Label&gt;
          ] UWCODE: [
          &lt;asp:Label ID="lblUw" runat="server" Text='&lt;%# Bind("UWFEECODE") %&gt;'&gt;&lt;/asp:Label&gt;
         ][
         &lt;asp:Label ID="lblUwDescription" runat="server" Text='&lt;%# Bind("DESCRIPTION") %&gt;'&gt;&lt;/asp:Label&gt;
         ]
         &lt;br /&gt;
         &lt;/td&gt;
         &lt;/tr&gt;                                                    
         &lt;/table&gt;
  
         &lt;table&gt;
           &lt;tr align="left" valign="top"&gt;
            &lt;td align="left"&gt;
             &lt;asp:DetailsView ID="dvEarner" runat="server" HeaderText="NO EARNER"
             EmptyDataText="No Results To Display" HeaderStyle-BorderColor="Black"
             HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px"
             BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None"
             BorderWidth="1px" CellPadding="3" CellSpacing="2" EnableViewState="False"&gt;
             &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
             &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
             &lt;PagerStyle ForeColor="#8C4510" HorizontalAlign="Center"/&gt;
             &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
             &lt;/asp:DetailsView&gt;
                                  &lt;/td&gt;
                                  &lt;td align="left"&gt;
                                      &lt;asp:DetailsView ID="dvJVName" runat="server" HeaderText="JV NAME"
                                          HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px"
                                          EmptyDataText="JV NAME"
                                          AlternatingRowStyle-BorderStyle="Solid" AlternatingRowStyle-BorderWidth="1px"
                                          BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None"
                                          BorderWidth="1px" CellPadding="3" CellSpacing="2"&gt;
                                          &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                          &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
                                          &lt;PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /&gt;
                                          &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                          &lt;EmptyDataRowStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="true" /&gt;
                                      &lt;/asp:DetailsView&gt;
                                  &lt;/td&gt;
                                  &lt;td align="left"&gt;
                                      &lt;asp:DetailsView ID="DetailsView1" runat="server" HeaderText="%"
                                          HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px"
                                          EmptyDataText="%"
                                          AlternatingRowStyle-BorderStyle="Solid" AlternatingRowStyle-BorderWidth="1px"
                                          BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None"
                                          BorderWidth="1px" CellPadding="3" CellSpacing="2"&gt;
                                          &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                          &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
                                          &lt;PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /&gt;
                                          &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                          &lt;EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /&gt;
                                          &lt;EmptyDataRowStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="true" /&gt;
                                      &lt;/asp:DetailsView&gt;
                                  &lt;/td&gt;
                                  &lt;td align="left"&gt;
                                      &lt;asp:DetailsView ID="dvProduct" runat="server" HeaderText="PRODUCT DETAILS"
                                          HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px"
                                          EmptyDataText="No Results To Display"
                                          AlternatingRowStyle-BorderStyle="Solid" AlternatingRowStyle-BorderWidth="1px"
                                          BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None"
                                          BorderWidth="1px" CellPadding="3" CellSpacing="2"&gt;
                                          &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                          &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
                                          &lt;PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /&gt;
                                          &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                      &lt;/asp:DetailsView&gt;
                                  &lt;/td&gt;
                                  &lt;td align="left"&gt;
                                      &lt;asp:DetailsView ID="dvFeeDetails" runat="server" HeaderText="ADDITIONAL FEE DETAILS"
                                          HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px"
                                          EmptyDataText="No Results To Display"
                                          AlternatingRowStyle-BorderStyle="Solid" AlternatingRowStyle-BorderWidth="1px"
                                          BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None"
                                          BorderWidth="1px" CellPadding="3" CellSpacing="2"&gt;
                                          &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                          &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
                                          &lt;PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /&gt;
                                          &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                      &lt;/asp:DetailsView&gt;
                                      &lt;br /&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;
  
               &lt;table&gt;
                               &lt;tr&gt;
                                  &lt;td&gt;
                                      &lt;strong&gt;&lt;u&gt;UNDERWRITER DETAILS:&lt;/u&gt;&lt;/strong&gt; 
                                      &lt;asp:GridView ID="grdUWDetails" runat="server" ForeColor="#333333" CellPadding="4" AutoGenerateSelectButton="False"&gt;
                                          &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
                                          &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                          &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt;
                                          &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                                          &lt;EmptyDataTemplate&gt;No results to display.&lt;/EmptyDataTemplate&gt;
                                      &lt;/asp:GridView&gt;
                                      &lt;br /&gt;
                                      &lt;hr /&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;
          &lt;/ItemTemplate&gt;
      &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>To bind my controls in my repeater:</p>
  
  <pre><code>Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As     System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
  If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
    Dim strPreno As String = DirectCast(e.Item.FindControl("lblPreno"), Label).Text
  
    Dim dv As DetailsView = DirectCast(e.Item.FindControl("dvEarner"), DetailsView)
    dv.DataSource = fnLoadPremiums(strPreno)
    dv.DataBind()
  
    Dim dv1 As DetailsView = DirectCast(e.Item.FindControl("dvProduct"), DetailsView)
    dv1.DataSource = fnLoadProduct(strPreno)
    dv1.DataBind()
  
    Dim dv2 As DetailsView = DirectCast(e.Item.FindControl("dvFeeDetails"), DetailsView)
    dv2.DataSource = fnLoadFeeDetails(strPreno)
    dv2.DataBind()
  
    Dim grd As GridView = DirectCast(e.Item.FindControl("grdUWDetails"), GridView)
  
    grd.DataSource = fnLoadGrid(strPreno)
    grd.DataBind()
  End If
  End Sub
  </code></pre>
  
  <p>Or if you have any ideas how to achieve this it would be much appreciated.</p>
  
  <p>I have used the datapager but I got this error: Control 'Repeater1' does not implement IPageableItemContainer. Then I did some researched about this the datapager only works with listview. So now I want the same method as the datapager but nor sure how to achieve this. Any Ideas?</p>