Change Gridviews Font Size Via C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yoda
    Contributor
    • Dec 2006
    • 291

    Change Gridviews Font Size Via C#

    Hey everyone,

    I would like to change the font size programmaticall y via C# to use pixels instead of the standard point system.

    The code below is what I have now and want to change it to use pixels instead.
    Code:
     GridView1.RowStyle.Font.Size = FontUnit.XSmall;
    Thanks,
    Yoda.
    Last edited by jhardman; Feb 18 '12, 01:09 AM. Reason: Moved to asp.net forum (accidentally posted in classic asp)
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    use the css style property directly
    Code:
     GridView1.Attributes.CSSStyle.Add("font-size","10px");

    Comment

    • yoda
      Contributor
      • Dec 2006
      • 291

      #3
      Thanks for the reply, but it seems that didn't do the trick either. I'm getting an error message:

      Error 'System.Web.UI. AttributeCollec tion' does not contain a definition for 'CSSStyle'

      Is it possible the CSSStyle property isn't available in .NET 2.0?

      EDIT:
      So I was correct it seems the CSSStyle property does not exist in .NET 2.0 :(
      Last edited by yoda; Feb 21 '12, 01:47 PM. Reason: Spelling / found the answer to my question about the .Net 2.0

      Comment

      • yarbrough40
        Contributor
        • Jun 2009
        • 320

        #4
        I typed this off the cuff. In C# the classes are case sensitive. type it like this: "CssStyle"

        Comment

        • yoda
          Contributor
          • Dec 2006
          • 291

          #5
          Thanks, I should have known to try the CssStyle instead of CSSStyle.

          Comment

          Working...