Another GridView Bug -> PagerSettings.Visible

Discussion in 'ASP .Net' started by gerry, Feb 23, 2007.

  1. gerry

    gerry Guest

    The PagerSettings.Visible property is not being handled properly by the
    GridView control.
    The value assigned to this property is not applied until after a postback.
    Simplest test :
    .aspx containing a single gridview - enable paging and give enough data
    to page.
    add checkbox with auto postback enable
    add button with auto postback enable
    in the GridView1_PreRender method add the following :
    GridView1.HeaderRow.Enabled =
    GridView1.PagerSettings.Visible =
    CheckBox1.Checked;
    note that the header should be enabled when the pager is visible and the
    header should be disabled whetn the pager is hidden.

    When you 1st view the page the header is disabled ( correct ) and the pager
    is visible ( incorrect )
    click the button and now the the header is disabled ( correct )and the pager
    is hidden ( correct )
    click the button as many times as you like , things remain as they shoud be.

    Click the checkbox - now the header is enabled ( correct ) and the pager is
    still hidden ( incorrect )
    click the button and now the the header is enabled ( correct ) and the pager
    is visible (correct )
    click the button as many times as you like , things remain as they shoud be.

    repeated clicking of the checkbox results in the header and pager being in
    opposite 'phase'.

    Having written my share of custom web controls, it is pretty obvious what
    the problem is.


    Has this been fixed with SP1 ? I am currently trying to install the update
    but after about 6 hours I am not having much success.


    Gerry
     
    gerry, Feb 23, 2007
    #1
    1. Advertising

  2. Gerry,
    You should look for this in the Product Feedback site, for a couple of
    reasons:
    1) other people may have already submitted it (or something very similar)
    and you can see the status of the alleged "bug" - including workarounds, if
    any.
    2) If it's a legitimate bug and nobody has submitted it, you have the honor
    of being the first.

    This page lists the different feedback sites by technology:

    http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220

    Cheers,
    Peter

    --
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short urls & more: http://ittyurl.net




    "gerry" wrote:

    > The PagerSettings.Visible property is not being handled properly by the
    > GridView control.
    > The value assigned to this property is not applied until after a postback.
    > Simplest test :
    > .aspx containing a single gridview - enable paging and give enough data
    > to page.
    > add checkbox with auto postback enable
    > add button with auto postback enable
    > in the GridView1_PreRender method add the following :
    > GridView1.HeaderRow.Enabled =
    > GridView1.PagerSettings.Visible =
    > CheckBox1.Checked;
    > note that the header should be enabled when the pager is visible and the
    > header should be disabled whetn the pager is hidden.
    >
    > When you 1st view the page the header is disabled ( correct ) and the pager
    > is visible ( incorrect )
    > click the button and now the the header is disabled ( correct )and the pager
    > is hidden ( correct )
    > click the button as many times as you like , things remain as they shoud be.
    >
    > Click the checkbox - now the header is enabled ( correct ) and the pager is
    > still hidden ( incorrect )
    > click the button and now the the header is enabled ( correct ) and the pager
    > is visible (correct )
    > click the button as many times as you like , things remain as they shoud be.
    >
    > repeated clicking of the checkbox results in the header and pager being in
    > opposite 'phase'.
    >
    > Having written my share of custom web controls, it is pretty obvious what
    > the problem is.
    >
    >
    > Has this been fixed with SP1 ? I am currently trying to install the update
    > but after about 6 hours I am not having much success.
    >
    >
    > Gerry
    >
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Feb 23, 2007
    #2
    1. Advertising

  3. Hi Gerry,

    In addtion to Peter's comments, whilst data has been bound, all rows have
    been already created based on values you provider at the binding stage (if
    PagerSetting.Visible was set to false, pager was not rendered, and even if
    you change it to true later in page execution it won't force gridview to show
    pager). It's also true for postback, because gridview rebuilds itself based
    on information stored in viewstate. To resolve the problem, you need to
    rebind the data again:

    // if autpostback is set to true you can handle CheckChanged event
    protected void myCheckBox_CheckedChanged(object sender, EventArgs e)
    {
    bool checked = ((CheckBox) sender).Checked;

    myGridView.PagerSettings.Visible = checked; // or !checked;
    myGridView.DataSource = dataSource;
    myGridView.dataBind();
    }

    Hope this helps

    --
    Milosz


    "Peter Bromberg [C# MVP]" wrote:

    > Gerry,
    > You should look for this in the Product Feedback site, for a couple of
    > reasons:
    > 1) other people may have already submitted it (or something very similar)
    > and you can see the status of the alleged "bug" - including workarounds, if
    > any.
    > 2) If it's a legitimate bug and nobody has submitted it, you have the honor
    > of being the first.
    >
    > This page lists the different feedback sites by technology:
    >
    > http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220
    >
    > Cheers,
    > Peter
    >
    > --
    > Site: http://www.eggheadcafe.com
    > UnBlog: http://petesbloggerama.blogspot.com
    > Short urls & more: http://ittyurl.net
    >
    >
    >
    >
    > "gerry" wrote:
    >
    > > The PagerSettings.Visible property is not being handled properly by the
    > > GridView control.
    > > The value assigned to this property is not applied until after a postback.
    > > Simplest test :
    > > .aspx containing a single gridview - enable paging and give enough data
    > > to page.
    > > add checkbox with auto postback enable
    > > add button with auto postback enable
    > > in the GridView1_PreRender method add the following :
    > > GridView1.HeaderRow.Enabled =
    > > GridView1.PagerSettings.Visible =
    > > CheckBox1.Checked;
    > > note that the header should be enabled when the pager is visible and the
    > > header should be disabled whetn the pager is hidden.
    > >
    > > When you 1st view the page the header is disabled ( correct ) and the pager
    > > is visible ( incorrect )
    > > click the button and now the the header is disabled ( correct )and the pager
    > > is hidden ( correct )
    > > click the button as many times as you like , things remain as they shoud be.
    > >
    > > Click the checkbox - now the header is enabled ( correct ) and the pager is
    > > still hidden ( incorrect )
    > > click the button and now the the header is enabled ( correct ) and the pager
    > > is visible (correct )
    > > click the button as many times as you like , things remain as they shoud be.
    > >
    > > repeated clicking of the checkbox results in the header and pager being in
    > > opposite 'phase'.
    > >
    > > Having written my share of custom web controls, it is pretty obvious what
    > > the problem is.
    > >
    > >
    > > Has this been fixed with SP1 ? I am currently trying to install the update
    > > but after about 6 hours I am not having much success.
    > >
    > >
    > > Gerry
    > >
    > >
    > >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Feb 24, 2007
    #3
  4. gerry

    gerry Guest

    I'm not sure if you are saying that this not a bug - if so i beg to disagree
    or at least to say that this a very very poor design.
    Why handle the PageSettings property any different than any other property
    on the control ? We can set any other property in PreRender and have it take
    effect on the current request without requiring a post back or a rebind.
    The real problem is that the designers of this control decided to treat the
    PagerRow different than the other non-data rows - HeaderRow & FooterRow.
    My workaround for this was to have the PagerSettings.Visible property always
    set to true ( which should not be required ) and capture the pager row
    object in the RowCreated event, then I use this PagerRow object to set pager
    visibility rather than the PagerSettings property whihc is then consistant
    with how we handle the properties of the HeaderRow & FooterRow.
    The PagerRow should have been setup as an exposed property the same as
    HeaderRow & FooterRow - I don't see any good reason why it wasn't.

    Gerry





    "Milosz Skalecki [MCAD]" <> wrote in message
    news:...
    > Hi Gerry,
    >
    > In addtion to Peter's comments, whilst data has been bound, all rows have
    > been already created based on values you provider at the binding stage (if
    > PagerSetting.Visible was set to false, pager was not rendered, and even if
    > you change it to true later in page execution it won't force gridview to
    > show
    > pager). It's also true for postback, because gridview rebuilds itself
    > based
    > on information stored in viewstate. To resolve the problem, you need to
    > rebind the data again:
    >
    > // if autpostback is set to true you can handle CheckChanged event
    > protected void myCheckBox_CheckedChanged(object sender, EventArgs e)
    > {
    > bool checked = ((CheckBox) sender).Checked;
    >
    > myGridView.PagerSettings.Visible = checked; // or !checked;
    > myGridView.DataSource = dataSource;
    > myGridView.dataBind();
    > }
    >
    > Hope this helps
    >
    > --
    > Milosz
    >
    >
    > "Peter Bromberg [C# MVP]" wrote:
    >
    >> Gerry,
    >> You should look for this in the Product Feedback site, for a couple of
    >> reasons:
    >> 1) other people may have already submitted it (or something very similar)
    >> and you can see the status of the alleged "bug" - including workarounds,
    >> if
    >> any.
    >> 2) If it's a legitimate bug and nobody has submitted it, you have the
    >> honor
    >> of being the first.
    >>
    >> This page lists the different feedback sites by technology:
    >>
    >> http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220
    >>
    >> Cheers,
    >> Peter
    >>
    >> --
    >> Site: http://www.eggheadcafe.com
    >> UnBlog: http://petesbloggerama.blogspot.com
    >> Short urls & more: http://ittyurl.net
    >>
    >>
    >>
    >>
    >> "gerry" wrote:
    >>
    >> > The PagerSettings.Visible property is not being handled properly by the
    >> > GridView control.
    >> > The value assigned to this property is not applied until after a
    >> > postback.
    >> > Simplest test :
    >> > .aspx containing a single gridview - enable paging and give enough
    >> > data
    >> > to page.
    >> > add checkbox with auto postback enable
    >> > add button with auto postback enable
    >> > in the GridView1_PreRender method add the following :
    >> > GridView1.HeaderRow.Enabled =
    >> > GridView1.PagerSettings.Visible =
    >> > CheckBox1.Checked;
    >> > note that the header should be enabled when the pager is visible and
    >> > the
    >> > header should be disabled whetn the pager is hidden.
    >> >
    >> > When you 1st view the page the header is disabled ( correct ) and the
    >> > pager
    >> > is visible ( incorrect )
    >> > click the button and now the the header is disabled ( correct )and the
    >> > pager
    >> > is hidden ( correct )
    >> > click the button as many times as you like , things remain as they
    >> > shoud be.
    >> >
    >> > Click the checkbox - now the header is enabled ( correct ) and the
    >> > pager is
    >> > still hidden ( incorrect )
    >> > click the button and now the the header is enabled ( correct ) and the
    >> > pager
    >> > is visible (correct )
    >> > click the button as many times as you like , things remain as they
    >> > shoud be.
    >> >
    >> > repeated clicking of the checkbox results in the header and pager being
    >> > in
    >> > opposite 'phase'.
    >> >
    >> > Having written my share of custom web controls, it is pretty obvious
    >> > what
    >> > the problem is.
    >> >
    >> >
    >> > Has this been fixed with SP1 ? I am currently trying to install the
    >> > update
    >> > but after about 6 hours I am not having much success.
    >> >
    >> >
    >> > Gerry
    >> >
    >> >
    >> >
     
    gerry, Feb 26, 2007
    #4
  5. gerry

    gerry Guest

    After looking at subclassing the GridView control to fix this short-coming ,
    it appears that maybe the problem is that the PagerSettings.PropertyChanged
    event is never fired
    Accoroding to the docs this is where the rebind should be happening with
    databound controls.

    So for now my subclass handles the PagerRow property under the resttriction
    that PagerSettings.Visible is not used at runtime.

    Gerry


    "gerry" <> wrote in message
    news:...
    > I'm not sure if you are saying that this not a bug - if so i beg to
    > disagree or at least to say that this a very very poor design.
    > Why handle the PageSettings property any different than any other property
    > on the control ? We can set any other property in PreRender and have it
    > take effect on the current request without requiring a post back or a
    > rebind.
    > The real problem is that the designers of this control decided to treat
    > the PagerRow different than the other non-data rows - HeaderRow &
    > FooterRow.
    > My workaround for this was to have the PagerSettings.Visible property
    > always set to true ( which should not be required ) and capture the pager
    > row object in the RowCreated event, then I use this PagerRow object to set
    > pager visibility rather than the PagerSettings property whihc is then
    > consistant with how we handle the properties of the HeaderRow & FooterRow.
    > The PagerRow should have been setup as an exposed property the same as
    > HeaderRow & FooterRow - I don't see any good reason why it wasn't.
    >
    > Gerry
    >
    >
    >
    >
    >
    > "Milosz Skalecki [MCAD]" <> wrote in message
    > news:...
    >> Hi Gerry,
    >>
    >> In addtion to Peter's comments, whilst data has been bound, all rows have
    >> been already created based on values you provider at the binding stage
    >> (if
    >> PagerSetting.Visible was set to false, pager was not rendered, and even
    >> if
    >> you change it to true later in page execution it won't force gridview to
    >> show
    >> pager). It's also true for postback, because gridview rebuilds itself
    >> based
    >> on information stored in viewstate. To resolve the problem, you need to
    >> rebind the data again:
    >>
    >> // if autpostback is set to true you can handle CheckChanged event
    >> protected void myCheckBox_CheckedChanged(object sender, EventArgs e)
    >> {
    >> bool checked = ((CheckBox) sender).Checked;
    >>
    >> myGridView.PagerSettings.Visible = checked; // or !checked;
    >> myGridView.DataSource = dataSource;
    >> myGridView.dataBind();
    >> }
    >>
    >> Hope this helps
    >>
    >> --
    >> Milosz
    >>
    >>
    >> "Peter Bromberg [C# MVP]" wrote:
    >>
    >>> Gerry,
    >>> You should look for this in the Product Feedback site, for a couple of
    >>> reasons:
    >>> 1) other people may have already submitted it (or something very
    >>> similar)
    >>> and you can see the status of the alleged "bug" - including workarounds,
    >>> if
    >>> any.
    >>> 2) If it's a legitimate bug and nobody has submitted it, you have the
    >>> honor
    >>> of being the first.
    >>>
    >>> This page lists the different feedback sites by technology:
    >>>
    >>> http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220
    >>>
    >>> Cheers,
    >>> Peter
    >>>
    >>> --
    >>> Site: http://www.eggheadcafe.com
    >>> UnBlog: http://petesbloggerama.blogspot.com
    >>> Short urls & more: http://ittyurl.net
    >>>
    >>>
    >>>
    >>>
    >>> "gerry" wrote:
    >>>
    >>> > The PagerSettings.Visible property is not being handled properly by
    >>> > the
    >>> > GridView control.
    >>> > The value assigned to this property is not applied until after a
    >>> > postback.
    >>> > Simplest test :
    >>> > .aspx containing a single gridview - enable paging and give enough
    >>> > data
    >>> > to page.
    >>> > add checkbox with auto postback enable
    >>> > add button with auto postback enable
    >>> > in the GridView1_PreRender method add the following :
    >>> > GridView1.HeaderRow.Enabled =
    >>> > GridView1.PagerSettings.Visible =
    >>> > CheckBox1.Checked;
    >>> > note that the header should be enabled when the pager is visible
    >>> > and the
    >>> > header should be disabled whetn the pager is hidden.
    >>> >
    >>> > When you 1st view the page the header is disabled ( correct ) and the
    >>> > pager
    >>> > is visible ( incorrect )
    >>> > click the button and now the the header is disabled ( correct )and the
    >>> > pager
    >>> > is hidden ( correct )
    >>> > click the button as many times as you like , things remain as they
    >>> > shoud be.
    >>> >
    >>> > Click the checkbox - now the header is enabled ( correct ) and the
    >>> > pager is
    >>> > still hidden ( incorrect )
    >>> > click the button and now the the header is enabled ( correct ) and the
    >>> > pager
    >>> > is visible (correct )
    >>> > click the button as many times as you like , things remain as they
    >>> > shoud be.
    >>> >
    >>> > repeated clicking of the checkbox results in the header and pager
    >>> > being in
    >>> > opposite 'phase'.
    >>> >
    >>> > Having written my share of custom web controls, it is pretty obvious
    >>> > what
    >>> > the problem is.
    >>> >
    >>> >
    >>> > Has this been fixed with SP1 ? I am currently trying to install the
    >>> > update
    >>> > but after about 6 hours I am not having much success.
    >>> >
    >>> >
    >>> > Gerry
    >>> >
    >>> >
    >>> >

    >
    >
     
    gerry, Feb 26, 2007
    #5
  6. gerry

    gerry Guest

    after more digging, i have dropped the subclass altogether as it turns out
    that there is in fact a PagerRow object - more precisely there are 2 of them
    TopPagerRow & BottomPagerRow.

    For now I will ignore the PagerSettings.Visible property and use the
    PagerRow properties to set their visible property.

    Gerry


    "gerry" <> wrote in message
    news:Oq0YE%...
    > After looking at subclassing the GridView control to fix this short-coming
    > ,
    > it appears that maybe the problem is that the
    > PagerSettings.PropertyChanged event is never fired
    > Accoroding to the docs this is where the rebind should be happening with
    > databound controls.
    >
    > So for now my subclass handles the PagerRow property under the
    > resttriction that PagerSettings.Visible is not used at runtime.
    >
    > Gerry
    >
    >
    > "gerry" <> wrote in message
    > news:...
    >> I'm not sure if you are saying that this not a bug - if so i beg to
    >> disagree or at least to say that this a very very poor design.
    >> Why handle the PageSettings property any different than any other
    >> property on the control ? We can set any other property in PreRender and
    >> have it take effect on the current request without requiring a post back
    >> or a rebind.
    >> The real problem is that the designers of this control decided to treat
    >> the PagerRow different than the other non-data rows - HeaderRow &
    >> FooterRow.
    >> My workaround for this was to have the PagerSettings.Visible property
    >> always set to true ( which should not be required ) and capture the pager
    >> row object in the RowCreated event, then I use this PagerRow object to
    >> set pager visibility rather than the PagerSettings property whihc is then
    >> consistant with how we handle the properties of the HeaderRow &
    >> FooterRow.
    >> The PagerRow should have been setup as an exposed property the same as
    >> HeaderRow & FooterRow - I don't see any good reason why it wasn't.
    >>
    >> Gerry
    >>
    >>
    >>
    >>
    >>
    >> "Milosz Skalecki [MCAD]" <> wrote in message
    >> news:...
    >>> Hi Gerry,
    >>>
    >>> In addtion to Peter's comments, whilst data has been bound, all rows
    >>> have
    >>> been already created based on values you provider at the binding stage
    >>> (if
    >>> PagerSetting.Visible was set to false, pager was not rendered, and even
    >>> if
    >>> you change it to true later in page execution it won't force gridview to
    >>> show
    >>> pager). It's also true for postback, because gridview rebuilds itself
    >>> based
    >>> on information stored in viewstate. To resolve the problem, you need to
    >>> rebind the data again:
    >>>
    >>> // if autpostback is set to true you can handle CheckChanged event
    >>> protected void myCheckBox_CheckedChanged(object sender, EventArgs e)
    >>> {
    >>> bool checked = ((CheckBox) sender).Checked;
    >>>
    >>> myGridView.PagerSettings.Visible = checked; // or !checked;
    >>> myGridView.DataSource = dataSource;
    >>> myGridView.dataBind();
    >>> }
    >>>
    >>> Hope this helps
    >>>
    >>> --
    >>> Milosz
    >>>
    >>>
    >>> "Peter Bromberg [C# MVP]" wrote:
    >>>
    >>>> Gerry,
    >>>> You should look for this in the Product Feedback site, for a couple of
    >>>> reasons:
    >>>> 1) other people may have already submitted it (or something very
    >>>> similar)
    >>>> and you can see the status of the alleged "bug" - including
    >>>> workarounds, if
    >>>> any.
    >>>> 2) If it's a legitimate bug and nobody has submitted it, you have the
    >>>> honor
    >>>> of being the first.
    >>>>
    >>>> This page lists the different feedback sites by technology:
    >>>>
    >>>> http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220
    >>>>
    >>>> Cheers,
    >>>> Peter
    >>>>
    >>>> --
    >>>> Site: http://www.eggheadcafe.com
    >>>> UnBlog: http://petesbloggerama.blogspot.com
    >>>> Short urls & more: http://ittyurl.net
    >>>>
    >>>>
    >>>>
    >>>>
    >>>> "gerry" wrote:
    >>>>
    >>>> > The PagerSettings.Visible property is not being handled properly by
    >>>> > the
    >>>> > GridView control.
    >>>> > The value assigned to this property is not applied until after a
    >>>> > postback.
    >>>> > Simplest test :
    >>>> > .aspx containing a single gridview - enable paging and give
    >>>> > enough data
    >>>> > to page.
    >>>> > add checkbox with auto postback enable
    >>>> > add button with auto postback enable
    >>>> > in the GridView1_PreRender method add the following :
    >>>> > GridView1.HeaderRow.Enabled =
    >>>> > GridView1.PagerSettings.Visible =
    >>>> > CheckBox1.Checked;
    >>>> > note that the header should be enabled when the pager is visible
    >>>> > and the
    >>>> > header should be disabled whetn the pager is hidden.
    >>>> >
    >>>> > When you 1st view the page the header is disabled ( correct ) and the
    >>>> > pager
    >>>> > is visible ( incorrect )
    >>>> > click the button and now the the header is disabled ( correct )and
    >>>> > the pager
    >>>> > is hidden ( correct )
    >>>> > click the button as many times as you like , things remain as they
    >>>> > shoud be.
    >>>> >
    >>>> > Click the checkbox - now the header is enabled ( correct ) and the
    >>>> > pager is
    >>>> > still hidden ( incorrect )
    >>>> > click the button and now the the header is enabled ( correct ) and
    >>>> > the pager
    >>>> > is visible (correct )
    >>>> > click the button as many times as you like , things remain as they
    >>>> > shoud be.
    >>>> >
    >>>> > repeated clicking of the checkbox results in the header and pager
    >>>> > being in
    >>>> > opposite 'phase'.
    >>>> >
    >>>> > Having written my share of custom web controls, it is pretty obvious
    >>>> > what
    >>>> > the problem is.
    >>>> >
    >>>> >
    >>>> > Has this been fixed with SP1 ? I am currently trying to install the
    >>>> > update
    >>>> > but after about 6 hours I am not having much success.
    >>>> >
    >>>> >
    >>>> > Gerry
    >>>> >
    >>>> >
    >>>> >

    >>
    >>

    >
    >
     
    gerry, Feb 26, 2007
    #6
  7. I have a BoundField column which I am dynamically adding to the GridView.

    BoundField boundField_Committed_date = new BoundField();
    boundField_Committed_date.DataField = "Committed_date";
    boundField_Committed_date.HeaderText = "Committed Dt";
    boundField_Committed_date.DataFormatString = "{0:d}";
    boundField_Committed_date.HtmlEncode = false;
    boundField_Committed_date.SortExpression = "Committed_date";

    I want to have the Visible property coming from the database and
    automatically binded. Visible property of course does not accept a Column
    Name. Is there any work around?
     
    =?Utf-8?B?QW5pbWVzaCBTYXhlbmE=?=, Feb 27, 2007
    #7
  8. Good morning Gerry,

    I disagree with you at some point. GridView control is based on templates
    and a data source. Dealing with data you have to consider it's only known at
    binding stage regardless if you use data table, data set or data reader. Most
    of the content within a template is based on data and in most cases binding
    stage is the only time you can build the control structure. And pager is a
    perfect example because it linked straight to the data - it can only be
    displayed if grid views contains any rows, it has to consider number of pages
    etc., not as for footer and header, they can be shown regardless if
    underlying data source contains any results. That’s why disagree with
    statement "…The real problem is that the designers of this control decided to
    treat the PagerRow different than the other non-data rows - HeaderRow &
    FooterRow…", because it a hybrid between data row and non data row :)

    Best Regards
    --
    Milosz


    "gerry" wrote:

    > I'm not sure if you are saying that this not a bug - if so i beg to disagree
    > or at least to say that this a very very poor design.
    > Why handle the PageSettings property any different than any other property
    > on the control ? We can set any other property in PreRender and have it take
    > effect on the current request without requiring a post back or a rebind.
    > The real problem is that the designers of this control decided to treat the
    > PagerRow different than the other non-data rows - HeaderRow & FooterRow.
    > My workaround for this was to have the PagerSettings.Visible property always
    > set to true ( which should not be required ) and capture the pager row
    > object in the RowCreated event, then I use this PagerRow object to set pager
    > visibility rather than the PagerSettings property whihc is then consistant
    > with how we handle the properties of the HeaderRow & FooterRow.
    > The PagerRow should have been setup as an exposed property the same as
    > HeaderRow & FooterRow - I don't see any good reason why it wasn't.
    >
    > Gerry
    >
    >
    >
    >
    >
    > "Milosz Skalecki [MCAD]" <> wrote in message
    > news:...
    > > Hi Gerry,
    > >
    > > In addtion to Peter's comments, whilst data has been bound, all rows have
    > > been already created based on values you provider at the binding stage (if
    > > PagerSetting.Visible was set to false, pager was not rendered, and even if
    > > you change it to true later in page execution it won't force gridview to
    > > show
    > > pager). It's also true for postback, because gridview rebuilds itself
    > > based
    > > on information stored in viewstate. To resolve the problem, you need to
    > > rebind the data again:
    > >
    > > // if autpostback is set to true you can handle CheckChanged event
    > > protected void myCheckBox_CheckedChanged(object sender, EventArgs e)
    > > {
    > > bool checked = ((CheckBox) sender).Checked;
    > >
    > > myGridView.PagerSettings.Visible = checked; // or !checked;
    > > myGridView.DataSource = dataSource;
    > > myGridView.dataBind();
    > > }
    > >
    > > Hope this helps
    > >
    > > --
    > > Milosz
    > >
    > >
    > > "Peter Bromberg [C# MVP]" wrote:
    > >
    > >> Gerry,
    > >> You should look for this in the Product Feedback site, for a couple of
    > >> reasons:
    > >> 1) other people may have already submitted it (or something very similar)
    > >> and you can see the status of the alleged "bug" - including workarounds,
    > >> if
    > >> any.
    > >> 2) If it's a legitimate bug and nobody has submitted it, you have the
    > >> honor
    > >> of being the first.
    > >>
    > >> This page lists the different feedback sites by technology:
    > >>
    > >> http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220
    > >>
    > >> Cheers,
    > >> Peter
    > >>
    > >> --
    > >> Site: http://www.eggheadcafe.com
    > >> UnBlog: http://petesbloggerama.blogspot.com
    > >> Short urls & more: http://ittyurl.net
    > >>
    > >>
    > >>
    > >>
    > >> "gerry" wrote:
    > >>
    > >> > The PagerSettings.Visible property is not being handled properly by the
    > >> > GridView control.
    > >> > The value assigned to this property is not applied until after a
    > >> > postback.
    > >> > Simplest test :
    > >> > .aspx containing a single gridview - enable paging and give enough
    > >> > data
    > >> > to page.
    > >> > add checkbox with auto postback enable
    > >> > add button with auto postback enable
    > >> > in the GridView1_PreRender method add the following :
    > >> > GridView1.HeaderRow.Enabled =
    > >> > GridView1.PagerSettings.Visible =
    > >> > CheckBox1.Checked;
    > >> > note that the header should be enabled when the pager is visible and
    > >> > the
    > >> > header should be disabled whetn the pager is hidden.
    > >> >
    > >> > When you 1st view the page the header is disabled ( correct ) and the
    > >> > pager
    > >> > is visible ( incorrect )
    > >> > click the button and now the the header is disabled ( correct )and the
    > >> > pager
    > >> > is hidden ( correct )
    > >> > click the button as many times as you like , things remain as they
    > >> > shoud be.
    > >> >
    > >> > Click the checkbox - now the header is enabled ( correct ) and the
    > >> > pager is
    > >> > still hidden ( incorrect )
    > >> > click the button and now the the header is enabled ( correct ) and the
    > >> > pager
    > >> > is visible (correct )
    > >> > click the button as many times as you like , things remain as they
    > >> > shoud be.
    > >> >
    > >> > repeated clicking of the checkbox results in the header and pager being
    > >> > in
    > >> > opposite 'phase'.
    > >> >
    > >> > Having written my share of custom web controls, it is pretty obvious
    > >> > what
    > >> > the problem is.
    > >> >
    > >> >
    > >> > Has this been fixed with SP1 ? I am currently trying to install the
    > >> > update
    > >> > but after about 6 hours I am not having much success.
    > >> >
    > >> >
    > >> > Gerry
    > >> >
    > >> >
    > >> >

    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Mar 1, 2007
    #8
  9. gerry

    gerry Guest

    Hi Milisz,
    I disagree with your disagreement. ;-) A pager row is no more tied to the
    data binding process than the header row especially if you have
    AutoGenerateColumns set to true.
    As it turns out I was partly wrong , as I stated in a followup post, the
    pager rows are treated the same as the header and footer rows AS LONG AS you
    always have the PagerSettings.Visible property set to true. So the real
    problem is how the that the PagerSettings.Visible property is applied - if
    you ignore it and use the actual PagerRow object(s) to set pager visiblility
    then everything works as it should. imo , the pager row object(s) should be
    created regardless of the PagerSettings.Visible property value and this
    value should be applied to the created objects. The way this control works
    , the PagerSettings.Visible property should have been called
    PagerSettings.Exists. Visibility is a UI property, not a DB property
    Gerry


    "Milosz Skalecki [MCAD]" <> wrote in message
    news:...
    > Good morning Gerry,
    >
    > I disagree with you at some point. GridView control is based on templates
    > and a data source. Dealing with data you have to consider it's only known
    > at
    > binding stage regardless if you use data table, data set or data reader.
    > Most
    > of the content within a template is based on data and in most cases
    > binding
    > stage is the only time you can build the control structure. And pager is a
    > perfect example because it linked straight to the data - it can only be
    > displayed if grid views contains any rows, it has to consider number of
    > pages
    > etc., not as for footer and header, they can be shown regardless if
    > underlying data source contains any results. That's why disagree with
    > statement ".The real problem is that the designers of this control decided
    > to
    > treat the PagerRow different than the other non-data rows - HeaderRow &
    > FooterRow.", because it a hybrid between data row and non data row :)
    >
    > Best Regards
    > --
    > Milosz
    >
    >
    > "gerry" wrote:
    >
    >> I'm not sure if you are saying that this not a bug - if so i beg to
    >> disagree
    >> or at least to say that this a very very poor design.
    >> Why handle the PageSettings property any different than any other
    >> property
    >> on the control ? We can set any other property in PreRender and have it
    >> take
    >> effect on the current request without requiring a post back or a rebind.
    >> The real problem is that the designers of this control decided to treat
    >> the
    >> PagerRow different than the other non-data rows - HeaderRow & FooterRow.
    >> My workaround for this was to have the PagerSettings.Visible property
    >> always
    >> set to true ( which should not be required ) and capture the pager row
    >> object in the RowCreated event, then I use this PagerRow object to set
    >> pager
    >> visibility rather than the PagerSettings property whihc is then
    >> consistant
    >> with how we handle the properties of the HeaderRow & FooterRow.
    >> The PagerRow should have been setup as an exposed property the same as
    >> HeaderRow & FooterRow - I don't see any good reason why it wasn't.
    >>
    >> Gerry
    >>
    >>
    >>
    >>
    >>
    >> "Milosz Skalecki [MCAD]" <> wrote in message
    >> news:...
    >> > Hi Gerry,
    >> >
    >> > In addtion to Peter's comments, whilst data has been bound, all rows
    >> > have
    >> > been already created based on values you provider at the binding stage
    >> > (if
    >> > PagerSetting.Visible was set to false, pager was not rendered, and even
    >> > if
    >> > you change it to true later in page execution it won't force gridview
    >> > to
    >> > show
    >> > pager). It's also true for postback, because gridview rebuilds itself
    >> > based
    >> > on information stored in viewstate. To resolve the problem, you need to
    >> > rebind the data again:
    >> >
    >> > // if autpostback is set to true you can handle CheckChanged event
    >> > protected void myCheckBox_CheckedChanged(object sender, EventArgs e)
    >> > {
    >> > bool checked = ((CheckBox) sender).Checked;
    >> >
    >> > myGridView.PagerSettings.Visible = checked; // or !checked;
    >> > myGridView.DataSource = dataSource;
    >> > myGridView.dataBind();
    >> > }
    >> >
    >> > Hope this helps
    >> >
    >> > --
    >> > Milosz
    >> >
    >> >
    >> > "Peter Bromberg [C# MVP]" wrote:
    >> >
    >> >> Gerry,
    >> >> You should look for this in the Product Feedback site, for a couple of
    >> >> reasons:
    >> >> 1) other people may have already submitted it (or something very
    >> >> similar)
    >> >> and you can see the status of the alleged "bug" - including
    >> >> workarounds,
    >> >> if
    >> >> any.
    >> >> 2) If it's a legitimate bug and nobody has submitted it, you have the
    >> >> honor
    >> >> of being the first.
    >> >>
    >> >> This page lists the different feedback sites by technology:
    >> >>
    >> >> http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220
    >> >>
    >> >> Cheers,
    >> >> Peter
    >> >>
    >> >> --
    >> >> Site: http://www.eggheadcafe.com
    >> >> UnBlog: http://petesbloggerama.blogspot.com
    >> >> Short urls & more: http://ittyurl.net
    >> >>
    >> >>
    >> >>
    >> >>
    >> >> "gerry" wrote:
    >> >>
    >> >> > The PagerSettings.Visible property is not being handled properly by
    >> >> > the
    >> >> > GridView control.
    >> >> > The value assigned to this property is not applied until after a
    >> >> > postback.
    >> >> > Simplest test :
    >> >> > .aspx containing a single gridview - enable paging and give
    >> >> > enough
    >> >> > data
    >> >> > to page.
    >> >> > add checkbox with auto postback enable
    >> >> > add button with auto postback enable
    >> >> > in the GridView1_PreRender method add the following :
    >> >> > GridView1.HeaderRow.Enabled =
    >> >> > GridView1.PagerSettings.Visible =
    >> >> > CheckBox1.Checked;
    >> >> > note that the header should be enabled when the pager is visible
    >> >> > and
    >> >> > the
    >> >> > header should be disabled whetn the pager is hidden.
    >> >> >
    >> >> > When you 1st view the page the header is disabled ( correct ) and
    >> >> > the
    >> >> > pager
    >> >> > is visible ( incorrect )
    >> >> > click the button and now the the header is disabled ( correct )and
    >> >> > the
    >> >> > pager
    >> >> > is hidden ( correct )
    >> >> > click the button as many times as you like , things remain as they
    >> >> > shoud be.
    >> >> >
    >> >> > Click the checkbox - now the header is enabled ( correct ) and the
    >> >> > pager is
    >> >> > still hidden ( incorrect )
    >> >> > click the button and now the the header is enabled ( correct ) and
    >> >> > the
    >> >> > pager
    >> >> > is visible (correct )
    >> >> > click the button as many times as you like , things remain as they
    >> >> > shoud be.
    >> >> >
    >> >> > repeated clicking of the checkbox results in the header and pager
    >> >> > being
    >> >> > in
    >> >> > opposite 'phase'.
    >> >> >
    >> >> > Having written my share of custom web controls, it is pretty obvious
    >> >> > what
    >> >> > the problem is.
    >> >> >
    >> >> >
    >> >> > Has this been fixed with SP1 ? I am currently trying to install the
    >> >> > update
    >> >> > but after about 6 hours I am not having much success.
    >> >> >
    >> >> >
    >> >> > Gerry
    >> >> >
    >> >> >
    >> >> >

    >>
    >>
    >>
     
    gerry, Mar 2, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. spamfurnace
    Replies:
    1
    Views:
    2,658
    Scott M.
    May 24, 2004
  2. tshad

    button visible/not visible

    tshad, Oct 26, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,479
    Brian Hoops
    Oct 28, 2004
  3. tshad

    Sections visible and not visible

    tshad, Jan 31, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,081
    tshad
    Jan 31, 2005
  4. cruster

    gridview pagersettings

    cruster, Sep 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    3,920
    Rob MacFadyen
    Sep 14, 2006
  5. waxabi

    Pagersettings postion in GridView

    waxabi, Jun 20, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    733
    Masudur
    Jun 20, 2007
Loading...

Share This Page