This is a migrated thread and some comments may be shown as answers.

Change PageSize of a RadDataPager

1 Answer 151 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Kurt
Top achievements
Rank 1
Kurt asked on 24 Apr 2010, 04:01 PM

I have a User Control with a ListView that is using the RadDataPager. I wanted to do something fairly simple and that was to have a PageSize property on my user control that could be used to set the RadDataPager.PageSize property.

Now, I did get this to working using the following code:

<telerik:RadDataPager ID="DataPager" runat="server" PagedControlID="myListView" 
                       PageSize="<%#this.PageSize%>"

The only issue I have with this is this that if the page size is different from whatever the default value is, the parent listview DataBound event is fired two times, once for the original page size, and a second time if a new value is specified.

Although this is not a big issue, it would be cool if there were a way to set the RadDataPager.PageSize property before its gets databaound; however, I was not able to find the "DataPager" using the listviews.FindControl method any earlier in the page life cycle.
I did try Page_Load, ListView.NeedDataSouce, ListView.DataBinding, ListView.Init.



1 Answer, 1 is accepted

Sort by
0
BaiH
Top achievements
Rank 1
answered on 27 Apr 2010, 04:45 PM
In order to access the DataPager, placed inside the ListView you can use LayoutCreated event. However as the pager is inside the ListView controls collection, changing the page size will always require at least two creation of the control's items. You may think about moving the pager outside of the ListView layout template and thus setting the PageSize property directly to it.

--BH
Tags
ListView
Asked by
Kurt
Top achievements
Rank 1
Answers by
BaiH
Top achievements
Rank 1
Share this question
or