[Mono-dev] GridView patches

Igor Zelmanovich igorz at mainsoft.com
Sun Jul 1 07:17:58 EDT 2007


Hi there.

I commited the patches and corresponding tests.
Take a look for r81138 and r81139

Thanks.

From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Dumitru Ban
Sent: Thursday, June 28, 2007 10:47 AM
To: mono-devel-list at lists.ximian.com
Subject: [Mono-dev] GridView patches

Hi,
 
I have 2 patches for the GridView. They are the result of trying to customize the pager of the GridView. I've created a CustomGridView derived from System.Web.UI.WebControls.GridView.
To customize the pager I'm using a pager template and override the InitializePager of the GridView:
protected override void InitializePager(GridViewRow row, int columnSpan, PagedDataSource pagedDataSource)
{
    if (this.ExtendedPager)
    {
        ExtendedPagerTemplate pagerTemplate = new ExtendedPagerTemplate(this.PageIndex, this.PageCount, this.PageSize, pagedDataSource.DataSourceCount, PagerStyle);
        base.PagerTemplate = pagerTemplate;
    }
    base.InitializePager(row, columnSpan, pagedDataSource);
}
 
Here is where the first problem appears. Because the GridView.PagerTemplare looks like this
public virtual ITemplate PagerTemplate {
    get { return pagerTemplate; }
    set { pagerTemplate = value; RequireBinding (); }
}
 
we will have infinte recursion. The RequireBinding() in the PagerTemplare should not be there. GridView_1.patch should fix this problem.
 
Also, I want the pager to be visible even if there is only one page. For this I override the CreateChildControls method of the GridView:
protected override int CreateChildControls(System.Collections.IEnumerable dataSource, bool dataBinding)
{
    int res = base.CreateChildControls(dataSource, dataBinding);
    if (PagerSettings.Visible == true)
    {
        if (PagerSettings.Position == PagerPosition.Bottom || PagerSettings.Position == PagerPosition.TopAndBottom)
            if (BottomPagerRow != null)
                BottomPagerRow.Visible = true;
        if (PagerSettings.Position == PagerPosition.Top || PagerSettings.Position == PagerPosition.TopAndBottom)
            if (TopPagerRow != null)
                TopPagerRow.Visible = true;
    }
    return res;
}
 
This works fine using Microsoft .NET. I've made some debugging and I saw that the pager is created even if there is only one page, but is not visible. The code written in the overridden CreateChildControls makes the pager to be visible. With MONO the pager is not created at all and the code written in the overridden CreateChildControls doesn't do anything because BottomPagerRow/TopPagerRow are null when only 1 page exists. GridView_2.patch should fix this problem. The patch also takes into account the value of PagerSetting.Visible for the pager creation.
 
Please review and apply them.
 
Thanks & best regards,
Dumi.



More information about the Mono-devel-list mailing list