Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. CSS setting in datagrid

CSS setting in datagrid

Scheduled Pinned Locked Moved ASP.NET
csshelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rain1178
    wrote on last edited by
    #1

    Hi, I am using Css to control the font setting in my web application. Everything work fine except datagrid. I want to set the header of my datagrid to bold = true and font =Comic Sans MS. And i also want to set the item in the datagrid to font size 11px. But i'm not able to see the expected result although i set those setting in the properties windows. I discover the font,font weight and font size is all follow what i define in TD part in my css sheet. Can anyone help me? This is my code..... Style.css /* Default CSS Stylesheet for a new Web Application project */ BODY { BACKGROUND-COLOR: #ffffff; FONT-FAMILY: Arial; FONT-WEIGHT: normal; LETTER-SPACING: normal; TEXT-TRANSFORM: none; WORD-SPACING: normal } TH { vertical-align: baseline; font-size: 1em; font-weight: normal; word-spacing: normal; letter-spacing: normal; text-transform: none; font-family: Arial, Helvetica, sans-serif; } TD { font-size: 12px; font-weight: normal; word-spacing: normal; letter-spacing: normal; text-transform: none; font-family: Arial, Helvetica, sans-serif; } A:link { text-decoration: none; color: #3333cc; } A:visited { text-decoration: none; color: #333399; } A:active { text-decoration: none; color: #333399; } A:hover { text-decoration: underline; color: #3333cc; } SMALL { font-size: .7em; } BIG { font-size: 1.17em; } BLOCKQUOTE, PRE { font-family: Courier New, monospace; } p { font-family: Arial, Helvetica, sans-serif; font:12px; font-weight:normal } Webform4.aspx <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm4.aspx.vb" Inherits="TryWeb.WebForm4"%> WebForm4

    R 1 Reply Last reply
    0
    • R rain1178

      Hi, I am using Css to control the font setting in my web application. Everything work fine except datagrid. I want to set the header of my datagrid to bold = true and font =Comic Sans MS. And i also want to set the item in the datagrid to font size 11px. But i'm not able to see the expected result although i set those setting in the properties windows. I discover the font,font weight and font size is all follow what i define in TD part in my css sheet. Can anyone help me? This is my code..... Style.css /* Default CSS Stylesheet for a new Web Application project */ BODY { BACKGROUND-COLOR: #ffffff; FONT-FAMILY: Arial; FONT-WEIGHT: normal; LETTER-SPACING: normal; TEXT-TRANSFORM: none; WORD-SPACING: normal } TH { vertical-align: baseline; font-size: 1em; font-weight: normal; word-spacing: normal; letter-spacing: normal; text-transform: none; font-family: Arial, Helvetica, sans-serif; } TD { font-size: 12px; font-weight: normal; word-spacing: normal; letter-spacing: normal; text-transform: none; font-family: Arial, Helvetica, sans-serif; } A:link { text-decoration: none; color: #3333cc; } A:visited { text-decoration: none; color: #333399; } A:active { text-decoration: none; color: #333399; } A:hover { text-decoration: underline; color: #3333cc; } SMALL { font-size: .7em; } BIG { font-size: 1.17em; } BLOCKQUOTE, PRE { font-family: Courier New, monospace; } p { font-family: Arial, Helvetica, sans-serif; font:12px; font-weight:normal } Webform4.aspx <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm4.aspx.vb" Inherits="TryWeb.WebForm4"%> WebForm4

      R Offline
      R Offline
      Ray Williams II
      wrote on last edited by
      #2

      Due to a flaw in the DataGrid control provided by Microsoft, it does not generate code compliant to the W3C standard. What this means for you and I is that table header's created by the DataGrid control will not render with <th/> tags. This flaw is documented on DataGrid Girl's website[^] and a fix has been posted to Microsoft support site[^]. Microsoft has not publicly released the fix, but provides a link to contact them for information. In the meantime... By renaming your TH style to "GridHeader" and adding the following line between your column tags, you will be able to impact the look of the header cells.

      <asp:boundcolumn, asp:templatecolumn, asp:ect...
      <HeaderStyle CssClass="GridHeader"/>
      </asp:boundcolumn, asp:templatecolumn, asp:ect...

      Unfortunately, this will not impact row level design elements.

      R 1 Reply Last reply
      0
      • R Ray Williams II

        Due to a flaw in the DataGrid control provided by Microsoft, it does not generate code compliant to the W3C standard. What this means for you and I is that table header's created by the DataGrid control will not render with <th/> tags. This flaw is documented on DataGrid Girl's website[^] and a fix has been posted to Microsoft support site[^]. Microsoft has not publicly released the fix, but provides a link to contact them for information. In the meantime... By renaming your TH style to "GridHeader" and adding the following line between your column tags, you will be able to impact the look of the header cells.

        <asp:boundcolumn, asp:templatecolumn, asp:ect...
        <HeaderStyle CssClass="GridHeader"/>
        </asp:boundcolumn, asp:templatecolumn, asp:ect...

        Unfortunately, this will not impact row level design elements.

        R Offline
        R Offline
        rain1178
        wrote on last edited by
        #3

        I follow the way u said,but i still can't get the output i wanted. This is the code i wrote, is that anything wrong in my code? /* Default CSS Stylesheet for a new Web Application project */ BODY { BACKGROUND-COLOR: #ffffff; FONT-FAMILY: Arial; FONT-WEIGHT: normal; LETTER-SPACING: normal; TEXT-TRANSFORM: none; WORD-SPACING: normal } GridHeader { vertical-align: baseline; font-size: 1em; font-weight: bold; font-family: Arial, Helvetica, sans-serif; } TD { font-size: 12px; font-weight: normal; word-spacing: normal; letter-spacing: normal; text-transform: none; font-family: Arial, Helvetica, sans-serif; } A:link { text-decoration: none; color: #3333cc; } A:visited { text-decoration: none; color: #333399; } A:active { text-decoration: none; color: #333399; } A:hover { text-decoration: underline; color: #3333cc; } SMALL { font-size: .7em; } BIG { font-size: 1.17em; } BLOCKQUOTE, PRE { font-family: Courier New, monospace; } p { font-family: Arial, Helvetica, sans-serif; font:12px; font-weight:normal } Datagrid code:

        R 1 Reply Last reply
        0
        • R rain1178

          I follow the way u said,but i still can't get the output i wanted. This is the code i wrote, is that anything wrong in my code? /* Default CSS Stylesheet for a new Web Application project */ BODY { BACKGROUND-COLOR: #ffffff; FONT-FAMILY: Arial; FONT-WEIGHT: normal; LETTER-SPACING: normal; TEXT-TRANSFORM: none; WORD-SPACING: normal } GridHeader { vertical-align: baseline; font-size: 1em; font-weight: bold; font-family: Arial, Helvetica, sans-serif; } TD { font-size: 12px; font-weight: normal; word-spacing: normal; letter-spacing: normal; text-transform: none; font-family: Arial, Helvetica, sans-serif; } A:link { text-decoration: none; color: #3333cc; } A:visited { text-decoration: none; color: #333399; } A:active { text-decoration: none; color: #333399; } A:hover { text-decoration: underline; color: #3333cc; } SMALL { font-size: .7em; } BIG { font-size: 1.17em; } BLOCKQUOTE, PRE { font-family: Courier New, monospace; } p { font-family: Arial, Helvetica, sans-serif; font:12px; font-weight:normal } Datagrid code:

          R Offline
          R Offline
          Ray Williams II
          wrote on last edited by
          #4

          Check the markup for your .CSS or Style section. The problem rests in your style sheet. Roughly stated, styles are defined based on three types: Tag, ID and Class. In your example;

          <style>
          ...

          GridHeader {
          vertical-align: baseline;
          font-size: 1em;
          font-weight: bold;
          font-family: Arial, Helvetica, sans-serif;
          }

          TD {
          font-size: 12px;
          font-weight: normal;
          word-spacing: normal;
          letter-spacing: normal;
          text-transform: none;
          font-family: Arial, Helvetica, sans-serif;
          }
          </style>

          you have defined [GridHeader] as a tag, which it is not. GridHeader should be defined as a class. Here is the corrected sytax.

          .GridHeader {
          vertical-align: baseline;
          font-size: 1em;
          font-weight: bold;
          font-family: Arial, Helvetica, sans-serif;
          }

          Note the classname is prefaced with a period (.). The period defines the scope of the style and allows the style to be applied to any number of elements on the page. This quick change should take care of the problems you are facing. UPDATE: Your markup for the style within the Datagrid does not change. You will still reference the style by its name only, without the period modifier.

          <headerStyle CssClass="GridHeader"/>

          R 1 Reply Last reply
          0
          • R Ray Williams II

            Check the markup for your .CSS or Style section. The problem rests in your style sheet. Roughly stated, styles are defined based on three types: Tag, ID and Class. In your example;

            <style>
            ...

            GridHeader {
            vertical-align: baseline;
            font-size: 1em;
            font-weight: bold;
            font-family: Arial, Helvetica, sans-serif;
            }

            TD {
            font-size: 12px;
            font-weight: normal;
            word-spacing: normal;
            letter-spacing: normal;
            text-transform: none;
            font-family: Arial, Helvetica, sans-serif;
            }
            </style>

            you have defined [GridHeader] as a tag, which it is not. GridHeader should be defined as a class. Here is the corrected sytax.

            .GridHeader {
            vertical-align: baseline;
            font-size: 1em;
            font-weight: bold;
            font-family: Arial, Helvetica, sans-serif;
            }

            Note the classname is prefaced with a period (.). The period defines the scope of the style and allows the style to be applied to any number of elements on the page. This quick change should take care of the problems you are facing. UPDATE: Your markup for the style within the Datagrid does not change. You will still reference the style by its name only, without the period modifier.

            <headerStyle CssClass="GridHeader"/>

            R Offline
            R Offline
            rain1178
            wrote on last edited by
            #5

            Thank you so much! My problem is solve :laugh:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups