-1

I am using the Repeater control. I can have around 300 records maximum.

I donot want to use Paging. There can be a provision to show More records with the help of More button at the bottom of Repeater.

Do you have any sample like that demonstrates such usage?

Caspar Kleijne
  • 21,552
  • 13
  • 72
  • 102
Nilish
  • 1,066
  • 3
  • 12
  • 26
  • 1
    In fact, you do want to use pagination, with this difference that your custom pager consists of only a _more_ button. – Caspar Kleijne May 08 '12 at 08:50
  • @CasparKleijne is right. I edited your question (waiting for approve atm) to show that. You want pagination, but not the usual one (1, 2, 3...) but the more (where you go to a web-service, wanna be, page load more content and return it to append to your response) – Michel Ayres May 08 '12 at 12:09

1 Answers1

0

As the commenter says you do need paging

You would need to use the PagedDataSource as the data source for the repeater. This link shows how. Because the repeater doesn't offer any 'out of the box' paging control you are free to code up whatever paging control you want - in your case the more button. From the link the databind would be something like

pagedDataSource page = new PagedDataSource();
            page.AllowCustomPaging = true;
            page.AllowPaging = true;
            page.DataSource = query;
            page.PageSize = 10;
            Repeater1.DataSource = page;
            Repeater1.DataBind();

Your paging might be something linq

protected btnMoreClick(object sender, EventArgs e)
{
    //.. get the source
    var dataSource = GetDataSource()

    //.. page it - i.e. use link
    dataSource.Skip(currentPage * pageSize).Take(pageSize)

    //.. now bind the source again
    //.. your code

}

Please note the above is pseudocode just to give you the idea and get you started.

ALSO

I posted a previous answer about efficient paging which I think would be relevant in your case.

Hope this helps

Community
  • 1
  • 1
Crab Bucket
  • 6,219
  • 8
  • 38
  • 73
  • Can I handle it in client side. Actually I want to add records on clicking the More Button. – Nilish May 08 '12 at 10:05
  • That should be straightforward then. The more button click will show a custom form with a save button. The user will fill the form and press a save button. The save event (server side) saves the record - either requery the database or manually insert the new record into the datasource for the repeater then use the updated source to rebind the repeater. The only issue might be that you will lose your position in the paging of the grid if you are doing it client side. Any help?? – Crab Bucket May 08 '12 at 11:00
  • I only have a repeater in my page. In case the records are coming more then 50. I have to show Move button at the bottom of 50 records . user presses the more. It will show another 50. Like that.... – Nilish May 08 '12 at 14:41
  • OK - then you aren't adding records you are paging them and my answer is valid. If there are specific questions regarding the implementation please ask but you're going to have to try to implement something really – Crab Bucket May 08 '12 at 14:45