Datapager and ListView inside a repeater

474 Views Asked by At

I have a Repeater with a ListView and its Datapager inside.

The information is populated correctly but, the datapager does not refresh the listview when clicking the page numer.

How do I refresh he list view based on datapager selection

<asp:Repeater runat="server" ID="Rptr" DataSourceID="Categories" >
   <asp:HiddenField runat="server" id="Hidden" Value='<%# Eval("Category") %.' />
   <ItemTemplate>
      <asp:DataPager runat="server" ID="DtPgr_Top" PagedControlID="List" PageSize="40">
           ...
      </asp:DataPager>
      <asp:ListView runat="server" ID="List"  DataSourceID="Items" >
         <ItemTemplate>
            ...
         </ItemTemplate>
      </asp:ListView>
      <asp:SqlDataSource runat="server" ID="Items" ConnectionString="<%$ ConnectionStrings:SAP_B1 %>"
        SelectCommand=" SELECT Item FROM Items WHERE Category = @Category " >
        <SelectParameters>
          <asp:ControlParameter ControlID="Hidden" Name="Category" PropertyName="Value" />
        </SelectParameters>
      </asp:SqlDataSource>    
   </ItemTemplate>

" SelectCommand=" SELECT Category FROM Categories " />

enter code here
1

There are 1 best solutions below

0
On

Solution 1 /

You have to put the listview outside the repeater.

Solution 2 /

Do not determine the datasource of repeater inline. Populate it from codebehind only once and only on load with - if not ispostback - directive.