Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
145
Code for CustomerPagerControl in base class?
posted

I have the Customer Pager Control example set up and working fine in my application.  The issue I have is that it seems to use this control I need to have some C# code in each class that uses it.  Since I do not want the other developers to have to add this code to every page that uses the control normally I would just move this code to the base class that all my pages inherit from but I am not able to do so and get things to work properly.  I can’t get a reference to WebFeatureBrowser_WebDataGrid_Paging_CustomerPagerControl so it will not compile.

Any help would be appreciated.

For an example of the code I am talking about you can see the WebDataGrid_AdvCustomPager.aspx.cs file in the samples for WebDataGrid, Paging – Custom Paging Template (as posted below):

  private WebFeatureBrowser_WebDataGrid_Paging_CustomerPagerControl pagerControl;

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        pagerControl = WebDataGridView.Behaviors.Paging.PagerTemplateContainer.FindControl("CustomerPager") as             WebFeatureBrowser_WebDataGrid_Paging_CustomerPagerControl;
        pagerControl.PageChanged += new EventHandler<PageChangedEventArgs>(currentPageControl_PageChanged);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    void currentPageControl_PageChanged(object sender, PageChangedEventArgs e)
    {
        this.WebDataGridView.Behaviors.Paging.PageIndex = e.PageNumber;
    }

    protected void WebDataGridView_DataBound(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            pagerControl.SetupPageList(this.WebDataGridView.Behaviors.Paging.PageCount);
        }
        pagerControl.SetCurrentPageNumber(WebDataGridView.Behaviors.Paging.PageIndex);
    }

  • 350
    posted

    The best way to get this to work is to create a composite user control that contains the WebDataGrid and the custom pager control. Than on each of your pages just use your composite user control (MyDataGrid).

    The MyDataGrid will need to contain all of the code (and markup) you normally would have put in your page for the WebDataGrid. In addition MyDataGrid will need to have a property or method for setting the data grid’s data source.

    Let me know if this was helpful.

    Todd Snyder