vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Saturday, October 27, 2012

DataPager control in asp.net


The DataPager control is designed to display the navigation for paging to the end user and
to coordinate data paging with any databound control.

Normally datapager control can be used to display the page number size in listview or any data control.
It’s have more option to custumize the page, because it’s completely separate control give the total freedom over where to place it on your webpage.

For an example here I used datapager control for listview.Its completely separate control from listview.
So we need to provide the connection between ListView and Datapager control.For that in datapager control have an option PagedControlID ="ListView1".Here we mention the listview control name to use for paging.

In an previous article I wrote about listview controls.Here I just linked the two articles to give paging for ListView.



Code:
<div>
        <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="5"
            OnPreRender="paging_render">
            <Fields>
                <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="true" />
                <asp:NumericPagerField ButtonCount="3" />
            </Fields>
        </asp:DataPager>
    </div>

On prerender we need to mention function name to bind the data in datapager control.so I have written a function on server side in the name of paging_render.so I declared it on the datapager.
Server Code:
protected void paging_render(object sender, EventArgs e)
    {
        //Load data is nothing to bind the data from database to listview.
        //****www.Dotnetcode.in******
        loaddata();
    }


I hope you like ..Post your comments here

0 comments:

Post a Comment