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

Discussion in 'ASP .Net Web Controls' started by Tom Castiglia, Jun 4, 2006.

  1. 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 Castiglia, Jun 4, 2006
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    >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
    >
    >
    Ken Cox [Microsoft MVP], Jun 7, 2006
    #2
    1. Advertising

  3. 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 [Microsoft MVP]" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >>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 Castiglia, Jun 9, 2006
    #3
    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. Vaclav Jedlicka

    datagrid and border-collapse:collapse style

    Vaclav Jedlicka, Jun 26, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,889
    Yan-Hong Huang[MSFT]
    Jun 30, 2003
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,693
    Smokey Grindel
    Dec 2, 2006
  3. chuckles
    Replies:
    2
    Views:
    527
    chuckles
    Aug 18, 2005
  4. VVSRKS

    How can I avoid border-collapse:collapse to come ...

    VVSRKS, Sep 16, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    183
    VVSRKS
    Sep 16, 2004
  5. jobs
    Replies:
    2
    Views:
    1,556
Loading...

Share This Page