Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 153431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:47:59+00:00 2026-05-11T09:47:59+00:00

In our application we have style sheets to define common colors etc… I wrote

  • 0

In our application we have style sheets to define common colors etc… I wrote a quick and dirty function where I get a dataset from a stored procedure, lop off the columns that I don’t want to show, cram it into a programmatically generated DataGrid, set that DataGrid’s styles, then export it to Excel. Everyone loves the colors in the Excel output (Gasp! They match the DataGrid colors, blah blah blah…).

My final piece I would like to add to it is that I would like to programmatically access a style and grab color codes and other items from it (.IntranetGridHead) instead of hard coding them, which is what I am doing now.

int iHeaderColor = Convert.ToInt32 ('D0D7E8', 16); DataGrid dg = new DataGrid(); dg.DataSource = dsReturnDataSet.Tables[0].DefaultView; dg.DataBind();  dg.HeaderStyle.BackColor = System.Drawing.Color.FromArgb(iHeaderColor); dg.HeaderStyle.Font.Bold = true; dg.HeaderStyle.Font.Size = 10; 

Obviously then whenever the company goes through another “rebranding” and the style sheet values change, the excel colors will automatically match and I will get a big (pat on the back||cookie).

Any thoughts from the C# people who know more than I (which would be most of you…)?
Thanks,
Michael

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:48:00+00:00Added an answer on May 11, 2026 at 9:48 am

    All Web.UI.Control objects have a .Styles property, which can be accessed as Styles[‘Name’]. Therefore you can do this:

    DataTable dt = LookupStyles(); dg.Styles.Clear(); foreach (DataRow dr in dt.Rows)   dg.Styles.Add(dr['StyleName'].ToString(), dr['StyleValue'].ToString()); 

    I had a similar thought several months ago 🙂 Note for this to work right, your grid must be runat=’server’.

    Edit: Looks like you want to READ the grid and use that… If you’re using a .CssStyle and a Stylesheet (.css), you’ll have to do an HTTP GET to that css file and parse it yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You want to use a datetime object instead of just… May 11, 2026 at 10:56 am
  • added an answer The unload event is raised in the control life-cycle right… May 11, 2026 at 10:56 am
  • added an answer For your first problem, you can use eq, which is… May 11, 2026 at 10:56 am

Related Questions

In our application we sometimes have to make minor GUI modifications for different customers:
In our web application we have a directory which resides outside of the project.
We have some issues in our application with skype taking over some of our
In our desktop application, we have implemented a simple search engine using an inverted
We have in the process of upgrading our application to full Unicode comptibility as
We have an application that downloads some files in the background. Our application pops
We're trying to get SMB volume listings in our OS X application, and have
We have some COBOL programs in our financial applications which need to interact with
In our application we've run into an error numerous times where we get error
In our application we enable users to print pages. We do this by supplying

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.