views:

106

answers:

2

Why is the following asp.net code not including styling information when being rendered to HTML?

<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" 
    GridLines="None">
    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="White" />
</asp:GridView>

Here is the HTML that is rendered:

<div class="AspNet-GridView" id="GridView1">
        <table cellpadding="0" cellspacing="0" summary="">
            <thead>
                <tr>
                    <th scope="col">Name</th>
                    <th scope="col">Age</th>
                    <th scope="col">Sex</th>
                </tr>

            </thead>
            <tbody>
                <tr>
                    <td>Ronnie</td>
                    <td>25</td>
                    <td>M</td>
                </tr>

                <tr class="AspNet-GridView-Alternate">
                    <td>Tina</td>
                    <td>25</td>
                    <td>F</td>
                </tr>
                <tr>
                    <td>Lukus</td>

                    <td>4</td>
                    <td>M</td>
                </tr>
            </tbody>
        </table>

</div>

There are no themes defined for this site. Any ideas what is going on?

EDIT

I created a new web site in VWD Express and copy and pasted my gridview code, which resulting in the following HTML being rendered:

<div>

    <table cellspacing="0" cellpadding="4" border="0" id="GridView1" style="color:#333333;border-collapse:collapse;">
        <tr style="color:White;background-color:#990000;font-weight:bold;">
            <th scope="col">Name</th><th scope="col">Age</th><th scope="col">Sex</th>
        </tr><tr style="color:#333333;background-color:#FFFBD6;">
            <td>Ronnie</td><td>25</td><td>M</td>
        </tr><tr style="color:#333333;background-color:White;">

            <td>Tina</td><td>25</td><td>F</td>
        </tr><tr style="color:#333333;background-color:#FFFBD6;">
            <td>Lukus</td><td>4</td><td>M</td>
        </tr>
    </table>
</div>

Something is keeping styling information from being included in my original project.

+1  A: 

If you want to know how to style your asp gridview you could check this page:

http://forums.asp.net/p/1001626/1426529.aspx

Tbh i don't know why your code ain't working.

Younes
Cheers for accepting ;)
Younes
+1  A: 

The problem was that I am using the CSS Friendly Control Adapters to make the Menu control render using unordered lists instead of tables. I had forgotten that the adapters change the way that many of the controls render, including the gridview.

So, in the CSSFriendlyAdapters.browser file, I commented out the controls that I wanted to render in the old fashioned way.

Ronnie Overby