articles

Home / DeveloperSection / Articles / DataPager Control in ASP.Net

DataPager Control in ASP.Net

Pushpendra Singh17797 08-Nov-2010

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.

DataPager Control in ASP.Net



Updated 04-Mar-2020

Leave Comment

Comments

Liked By