DataPager control can be associated with the data-bound control by using the PagedControlID property. Alternatively, by putting the DataPager control inside the data-bound control hierarchy. For example, in the ListView control, DataPager control can be kept inside the ListView-Layout Template. The number of items that are displayed for each page of data can be customized by changing the Page Size property. The way a page is submitted to the server can be changed by setting the QueryStringField property.
Page Properties:
The following table lists read-only properties of the DataPager control that specify characteristics of the page of data. These properties are usually used for binding expressions in the TemplatePagerField object.
Property | Description |
Maximum Rows | The maximum number of records that are displayed for each page of data. |
StartRowIndex | The index of the first record that is displayed on a page of data. |
TotalRowCount | The total number of records that are available in the underlying data source. |
<asp:DataPagerrunat="server"ID="EmployeesDataPager"PageSize="1"PagedControlID="ListView1"
OnPreRender="EmployeesDataPager_PreRender">
<Fields>
<asp:NumericPagerField/>
</Fields>
</asp:DataPager>
Bind Data in DataPager PreRender event
Write below code in DataPager PreRender event
protectedvoid EmployeesDataPager_PreRender(object sender, EventArgs e)
{
ListView1.DataSource = Class1.execute_spfill_grid("insert_reg");
ListView1.DataBind();
}
In above code execute_spfill_grid is a function created in Class1 and insert_reg is a stored procedure.
Shrikant Mishra
13-Aug-2020Hi,
PUSHPENDRA SINGH JI
Your article helped me a lot to practice my programming. Thank you too!!
Anonymous User
22-Feb-2019Thank You.
Sushant Mishra
24-Jul-2017I am grateful to you, for sharing a post like this.