Home All Groups Group Topic Archive Search About

Why does Gridview ALWAYS emit style="border-collapse: collapse;"

Author
4 Jun 2006 9:49 PM
Tom Castiglia
I am inheriting from the GridView and I noticed the GridView ALWAYS emits its
table tag with a style attribute containing "border-collapse: collapse".  I
have tried everything that I can think of to remove this style, but without
results.

I have tried the following:

Attributes.CssStyle.Remove(HtmlTextWriterStyle.BorderCollapse);
Attributes.CssStyle.Clear()

I have attempted this from the RenderContents(), OnInit(), and OnPreRender()
methods.  The problem is that even in the RenderContents() method, the
Attributes.CssStyle.Count properties is 0.  So it seems that the
Border-Collapse style is not added until a later point in the control's
lifecycle.

Any thoughts on this?  It seems to be really improper for the Gridview to
inject this style into HTML.  I really need to control the control's style
through a CssClass.

--
Tom Castiglia
tom.castig***@gmail.com
tcastig***@hersheytech.com

Author
7 Jun 2006 3:20 AM
Ken Cox [Microsoft MVP]
Hi Tom,

It's incorrectly hardcoded in ASP.NET in some places.

Try this?

     GridView1.GridLines =  GridLines.None
      GridView1.CellSpacing=-1

Note that you'll still get

border="0"

Nothing can be done about that til there's an update.

Let us know if this helps?


Ken
Microsoft MVP [ASP.NET]


Show quoteHide quote
"Tom Castiglia" <tom.castiglia@no-gmail-spam.com> wrote in message
news:39CB7C23-50F7-48F3-BD74-3F1A24CC77D3@microsoft.com...
>I am inheriting from the GridView and I noticed the GridView ALWAYS emits
>its
> table tag with a style attribute containing "border-collapse: collapse".
> I
> have tried everything that I can think of to remove this style, but
> without
> results.
>
> I have tried the following:
>
> Attributes.CssStyle.Remove(HtmlTextWriterStyle.BorderCollapse);
> Attributes.CssStyle.Clear()
>
> I have attempted this from the RenderContents(), OnInit(), and
> OnPreRender()
> methods.  The problem is that even in the RenderContents() method, the
> Attributes.CssStyle.Count properties is 0.  So it seems that the
> Border-Collapse style is not added until a later point in the control's
> lifecycle.
>
> Any thoughts on this?  It seems to be really improper for the Gridview to
> inject this style into HTML.  I really need to control the control's style
> through a CssClass.
>
> --
> Tom Castiglia
> tom.castig***@gmail.com
> tcastig***@hersheytech.com
Author
9 Jun 2006 3:18 AM
Tom Castiglia
Ken,

Thank you...That worked!

Can you also figure out how to get me back the 10 hours I spent working on
this problem?

Tom Castiglia
Hershey Technologies


Show quoteHide quote
"Ken Cox [Microsoft MVP]" <BANSPAMkjopc@newsgroups.nospam> wrote in message
news:OrnsNFeiGHA.1600@TK2MSFTNGP04.phx.gbl...
> Hi Tom,
>
> It's incorrectly hardcoded in ASP.NET in some places.
>
> Try this?
>
>     GridView1.GridLines =  GridLines.None
>      GridView1.CellSpacing=-1
>
> Note that you'll still get
>
> border="0"
>
> Nothing can be done about that til there's an update.
>
> Let us know if this helps?
>
>
> Ken
> Microsoft MVP [ASP.NET]
>
>
> "Tom Castiglia" <tom.castiglia@no-gmail-spam.com> wrote in message
> news:39CB7C23-50F7-48F3-BD74-3F1A24CC77D3@microsoft.com...
>>I am inheriting from the GridView and I noticed the GridView ALWAYS emits
>>its
>> table tag with a style attribute containing "border-collapse: collapse".
>> I
>> have tried everything that I can think of to remove this style, but
>> without
>> results.
>>
>> I have tried the following:
>>
>> Attributes.CssStyle.Remove(HtmlTextWriterStyle.BorderCollapse);
>> Attributes.CssStyle.Clear()
>>
>> I have attempted this from the RenderContents(), OnInit(), and
>> OnPreRender()
>> methods.  The problem is that even in the RenderContents() method, the
>> Attributes.CssStyle.Count properties is 0.  So it seems that the
>> Border-Collapse style is not added until a later point in the control's
>> lifecycle.
>>
>> Any thoughts on this?  It seems to be really improper for the Gridview to
>> inject this style into HTML.  I really need to control the control's
>> style
>> through a CssClass.
>>
>> --
>> Tom Castiglia
>> tom.castig***@gmail.com
>> tcastig***@hersheytech.com
>
>
Author
8 Jul 2006 3:32 PM
Steve Roberts
I'm having a very similar problem with the Login control - again it always generates a default style containing 'border-collapse' - only in this case the control doesn't appear to have a GridLines or CellSpacing attribute - how can I change the style in this case? Regards, Steve

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/