Thursday, December 15, 2011

How to programmatically set DataPager PageSize

DataPager1.PageSize = xx

Where xx is the size (Integer), you could put it in the Page_Init or Page_Load event, before any DataBind.
If your DataPager is within the ListView you'd have to find it first, and you could do that using the FindControl method.
If the DataPager is outside the Listview obviously, you don't have to find it using the FindControl method.
Also, If you're not using a data source (like the SqlDataSource) you would also provide the .DataSource property before you execute .DataBind on your Listview.

Submit this story to DotNetKicks