开发者

asp:DataPager onclick event

I am working with the .Net List view along with a data pager to enable pagination for a list view.

开发者_StackOverflowI am able to set the pagination working perfectly for the list view but I wish to have a method being called when ever the user clicks on any of the page numbers in the data pager.

I want to perform some operation whenever the page number is called. I guess there is no onclick event, so is there any other way by which this is possible.

Thanks


you can set it as imagebutton or linkbutton.

I have piece of code.. you just need to implement it.

you can set link and click event.

foreach (DataPagerFieldItem dpfItem in dtpPaging.Controls)
            {
                foreach (Control cPagerControls in dpfItem.Controls)
                {
                    if (cPagerControls is ImageButton)
                    {
                        ImageButton imgNavigation = cPagerControls as ImageButton;
                        imgNavigation.PostBackUrl = CommonLogic.GetFormattedURL(strPageUrl);
                        imgNavigation.Click += new ImageClickEventHandler(imgNavigation_Click);

                    }
                    if (cPagerControls is LinkButton)
                    {
                        LinkButton lnkNumbers = cPagerControls as LinkButton;
                        lnkNumbers.PostBackUrl = CommonLogic.GetFormattedURL(strPageUrl);
                        lnkNumbers.Click += new EventHandler(lnkNumbers_Click);
                    }
                }
            }


You can bind a handler to the OnPagePropertiesChanging Event of the List View. A PagePropertiesChangingEventArgs object is passed to the handler as argument which contains MaximumRows and StartRowIndex properties. You can use these to calculate the current page number. It is very easy and requires no code-behind event binding as the solution proposed by sikender.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜