Asp.net 2.0 – Gridview Skin and CSS Question
Question:
I have a web application that has several pages each with its own gridview. I want to use a skin file so each will have a consistant look.
I would like to be able to get each row’s control field displayed as a button rather than a link but when I add <Columns> to the skin file, the gridview displays only the command field and no data. I’m attaching both the skin file and the CSS file.
If I delete, the “Columns” portion of the skin file, it works but the default command field is diaplayed.
Is there any way to do this where I don’t have to add code for the command field on each page?
Thanks in advance for any help.
Code Snippet:
(Skin File)
<asp:GridView runat=”server” SkinID=”Admin” CssClass=”DataWebControlStyle”>
<AlternatingRowStyle CssClass=”AlternatingRowStyle” />
<RowStyle CssClass=”RowStyle” />
<HeaderStyle CssClass=”HeaderStyle” />
<PagerStyle CssClass=”PagerStyle” />
<Columns>
<asp:CommandField ShowEditButton=”True” >
<ControlStyle CssClass=”ControlStyle” />
</asp:CommandField>
</Columns>
</asp:GridView>
CSS FILE
.DataWebControlStyle {
color: #333333;
font-size: small;
padding: 5;
}
.HeaderStyle {
background-color: #d08688;
color: White;
font-weight: bold;
font-size: small;
font-family: Times New Roman;
}
.HeaderStyle A:Link {
color: White; }
.AlternatingRowStyle {
background-color: White;
color: #BD5356;
}
.RowStyle {
background-color: #f2dddd;
color: #792f30;
}
.ControlStyle {
color: #91393b;
}
.PagerStyle {
background-color: #9e3d40;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: xx-small;
color: White;
}
.PagerStyle A:Link {
color: White; }
Solution:
If you define columns in the skin file for the GridView, then it overrides what the web page is defining for columns. I don’t believe that you can pre-defined CommandField columns in a skin file that way…













Comments (0)
Trackbacks - Pingbacks (0)
Leave a Reply