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

T

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.
 
K

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]
 
T

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


Ken Cox said:
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]
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top