How to dynamically disable GridView"s alternaterowstyle?

How to dynamically disable GridView"s alternaterowstyle?

am 01.02.2008 16:37:28 von gnewsgroup

I am creating GridView(s) on the fly and add them to a PlaceHolder
control. The skin file of my application orders GridViews to have an
alternate row style.

But on this particular aspx page, I do NOT want alternate row style
for GridView(s). In other words, I want it plain white with grid
lines.

I tried setting Theme and StylesheetTheme to empty strings in the page
directive, but then my page header and footer all lost the pre-defined
styles.

I was hoping that I could do something like

myDynamicGridView.EnableAlternateRowStyle = false;

But, of course there is no such thing as EnableAlternateRowStyle.

So, how do I disable alternate row style? Thank you.

RE: How to dynamically disable GridView"s alternaterowstyle?

am 01.02.2008 22:21:22 von rodoopus

I've been grapping about this sort of thing for a while. This is the problem
you find your self in when you rely too much on the declarative model.

I tried what I think you were describing and was able to easily alternate
between plain and alternate. My choice of colors sucks but it gets the point
across

For demo:

Two buttons

Protected Sub Button1_click (ByVal Sender As Object, ByVal e as
system.eventArgs) handles button1.Click

Gridview1.AlternatingRowStyle.BackColor = Drawing.color.Gainsboro
Gridview1.AlternatingRowStyle.ForeColor = Drawing.color.White
Gridview1.DataBind()

End Sub

Protected Sub Button1_click (ByVal Sender As Object, ByVal e as
system.eventArgs) handles button1.Click
Gridview1.AlternatingRowStyle.BackColor = Gridview1.RowStyle.BaclColor
Gridview1.AlternatingRowStyle.ForeColor = Gridview1.RowStyle.ForeColor
Gridview1.DataBind()
End Sub

the Gridview1.DataBind may not be needed it depends on how you have
viewstate setup and other factors. It would not be difficult to replace the
button with logic

hope it helps
--
aaa


"gnewsgroup" wrote:

> I am creating GridView(s) on the fly and add them to a PlaceHolder
> control. The skin file of my application orders GridViews to have an
> alternate row style.
>
> But on this particular aspx page, I do NOT want alternate row style
> for GridView(s). In other words, I want it plain white with grid
> lines.
>
> I tried setting Theme and StylesheetTheme to empty strings in the page
> directive, but then my page header and footer all lost the pre-defined
> styles.
>
> I was hoping that I could do something like
>
> myDynamicGridView.EnableAlternateRowStyle = false;
>
> But, of course there is no such thing as EnableAlternateRowStyle.
>
> So, how do I disable alternate row style? Thank you.
>

Re: How to dynamically disable GridView"s alternaterowstyle?

am 01.02.2008 22:45:55 von gnewsgroup

On Feb 1, 4:21=A0pm, Angel wrote:
> I've been grapping about this sort of thing for a while. This is the probl=
em
> you find your self in when you rely too much on the declarative model.
>
> I tried what I think you were describing and was able to easily alternate
> between plain and alternate. =A0My choice of colors sucks but it gets the =
point
> across
>
> For demo: =A0
>
> Two buttons
>
> Protected Sub Button1_click (ByVal Sender As Object, ByVal e as
> system.eventArgs) handles button1.Click
>
> Gridview1.AlternatingRowStyle.BackColor =3D Drawing.color.Gainsboro
> =A0 =A0 =A0 =A0 Gridview1.AlternatingRowStyle.ForeColor =3D Drawing.color.=
White
> =A0 =A0 =A0 =A0 Gridview1.DataBind()
>
> End Sub
>
> Protected Sub Button1_click (ByVal Sender As Object, ByVal e as
> system.eventArgs) handles button1.Click
> Gridview1.AlternatingRowStyle.BackColor =3D Gridview1.RowStyle.BaclColor
> =A0 =A0 =A0 =A0 Gridview1.AlternatingRowStyle.ForeColor =3D Gridview1.RowS=
tyle.ForeColor
> =A0 =A0 =A0 =A0 Gridview1.DataBind()
> End Sub
>
> the Gridview1.DataBind may not be needed it depends on how you have
> viewstate setup and other factors. =A0It would not be difficult to replace=
the
> button with logic
>
> hope it helps
> --
> aaa
>
>
>
> "gnewsgroup" wrote:
> > I am creating GridView(s) on the fly and add them to a PlaceHolder
> > control. =A0The skin file of my application orders GridViews to have an
> > alternate row style.
>
> > But on this particular aspx page, I do NOT want alternate row style
> > for GridView(s). =A0In other words, I want it plain white with grid
> > lines.
>
> > I tried setting Theme and StylesheetTheme to empty strings in the page
> > directive, but then my page header and footer all lost the pre-defined
> > styles.
>
> > I was hoping that I could do something like
>
> > myDynamicGridView.EnableAlternateRowStyle =3D false;
>
> > But, of course there is no such thing as EnableAlternateRowStyle.
>
> > So, how do I disable alternate row style? =A0Thank you.- Hide quoted tex=
t -
>
> - Show quoted text -

Thank you very much. But, I think I said that I do NOT want alternate
row style. I want to dynamically disable alternate row style.