Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Another GridView Bug -> PagerSettings.Visible

Reply
Thread Tools

Another GridView Bug -> PagerSettings.Visible

 
 
gerry
Guest
Posts: n/a
 
      02-23-2007
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      02-23-2007
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/co...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
>
>
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      02-24-2007
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/co...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
> >
> >
> >

 
Reply With Quote
 
gerry
Guest
Posts: n/a
 
      02-26-2007
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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/co...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
>> >
>> >
>> >



 
Reply With Quote
 
gerry
Guest
Posts: n/a
 
      02-26-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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/co...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
>>> >
>>> >
>>> >

>
>



 
Reply With Quote
 
gerry
Guest
Posts: n/a
 
      02-26-2007
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" <(E-Mail Removed)> wrote in message
news:Oq0YE%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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]" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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/co...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
>>>> >
>>>> >
>>>> >

>>
>>

>
>



 
Reply With Quote
 
=?Utf-8?B?QW5pbWVzaCBTYXhlbmE=?=
Guest
Posts: n/a
 
      02-27-2007
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?


 
Reply With Quote
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      03-01-2007
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]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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/co...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
> >> >
> >> >
> >> >

>
>
>

 
Reply With Quote
 
gerry
Guest
Posts: n/a
 
      03-02-2007
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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]" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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/co...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
>> >> >
>> >> >
>> >> >

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to stop editing another row in a Gridview, ReorderList etc when another row is already being edited Andrew Jocelyn ASP .Net 2 04-27-2009 02:01 AM
gridview column values to another page via gridview hyperlink column Keith G Hicks ASP .Net 3 02-18-2008 06:17 AM
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
Re: BUG? OR NOT A BUG? John ASP .Net 2 09-21-2005 10:31 AM



Advertisments