0

Is it possible to add paging for content foremed using repeaters

<asp:Repeater ID="Repeater1" runat="server">
   <ItemTemplate>
      <div class="row">
         <div class="col-sm-6">
         <!--One card-->
            <div class="card" style="width: 90%">
               <div class="card-body"> 
                  <asp:Label ID="Label3" runat="server" Text="Name"></asp:Label>      
               </div>
            </div>
          </div>
      </div>
   </ItemTemplate>            
</asp:Repeater>

By doing this i get cards according to the data in the database one under the other this will not be practical if there are a lot of data

will i be able to implement paging for this

First 1 2 3...... Last

I am not using a datatable DataTable dt = new DataTable();

I am using DataSet ds = new DataSet();

How to change the code

//save the result in data table     
DataTable dt = new DataTable();     
ad.SelectCommand = cmd;     
ad.Fill(dt);      
//Create the PagedDataSource that will be used in paging     
PagedDataSource pgitems = new PagedDataSource();     
pgitems.DataSource = dt.DefaultView;     
pgitems.AllowPaging = true; 

according to the one i use below

DataSet ds = new DataSet();           
SqlDataAdapter da = new SqlDataAdapter(cmd);             
da.Fill(ds);                          
Repeater1.DataSource = ds;   

I cant put

pgitems.DataSource = ds.DefaultView;

it gives me an error

  • How is this related to the SQL _language_? – jarlh Dec 22 '20 at 13:50
  • Here is some example it may help but you will require to learn many things https://www.c-sharpcorner.com/article/paging-using-repeater-control-in-asp-net-with-and-without-stored-procedure/ – शेखर Dec 22 '20 at 13:53
  • I've removed the SQL tag for you. If you need help with your query, please re-add the SQL tag, and add the query to your question. – ProgrammingLlama Dec 22 '20 at 13:55
  • 1
    Similar to this? [How to use paging with Repeater control in ASP.NET?](https://stackoverflow.com/questions/22904666/how-to-use-paging-with-repeater-control-in-asp-net) – Pirate Dec 22 '20 at 13:57
  • @Pirate in the link you provided it has `//save the result in data table DataTable dt = new DataTable(); ad.SelectCommand = cmd; ad.Fill(dt); //Create the PagedDataSource that will be used in paging PagedDataSource pgitems = new PagedDataSource(); pgitems.DataSource = dt.DefaultView; pgitems.AllowPaging = true;` but i use `DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); Repeater1.DataSource = ds; Repeater1.DataBind();` error at `dt.DefaultView;` –  Dec 22 '20 at 14:15
  • You know a DataSet uses a DataTable, right? – mason Dec 22 '20 at 15:04
  • I dont know how to convert it would be a great help if u can write that coding lines because when i put ds.DefaultView it gives an error –  Dec 22 '20 at 15:30

0 Answers0