Solved

Adding my own style to the built-in datagrid auto-format list

Posted on 2004-08-25
17
335 Views
Last Modified: 2008-02-01
I am updating a website that has a large number of datagrids and I want to change the colours on each one to the new standard. It will be really tedious and time-consuming to edit each datagrid, so is there a way I can add my style to the built-in list, and simply use auto-format on them?
0
Comment
Question by:crescendo
  • 5
  • 5
  • 3
  • +1
17 Comments
 
LVL 3

Expert Comment

by:a_ro_no
ID: 11891329
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11891363
Just paste your css in the head of your .aspx file and then set the css class property of the datagrid to the name of your css class.  Easy!!

Regards,

Aeros
0
 
LVL 9

Author Comment

by:crescendo
ID: 11891481
Hi both

CSS solutions work fine if the parts of the datagrids (items, headers, footers etc) have consistent CssClass names across the site, but they don't, and I'm trying to avoid editing every datagrid in that much detail to make them consistent.

Any other ideas? Surely there must be a way of modifying the built-in styles?
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11891726
you can use the property builder in the IDE as well as the stylebuilder.

regards,

Aeros
0
 
LVL 9

Author Comment

by:crescendo
ID: 11891747
Aeros

But then I'd have to format them all individually wouldn't I?
0
 
LVL 3

Expert Comment

by:a_ro_no
ID: 11892086
if you use css file, you should add
<LINK href="Styles.css" type="text/css" rel="stylesheet">
in the head tag of aspx page.

or you can add
<style>
     .grid{
          font-size:     10pt;
          color: #000086;
          background-color: White;
.....
}    
</style>
in the head tag of aspx page

It is just copy paste... ;)
0
 
LVL 3

Expert Comment

by:a_ro_no
ID: 11892118
After that if you want to change the style of your grid the only thing you will have to do is to modify the stylesheet!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:a_ro_no
ID: 11892156
Ooops i haven't noticed your post sorry...!
Inheritance is definitelly one way...
Perhups building a custom control that derives from datagrid control... I'll check it.
0
 
LVL 8

Expert Comment

by:shovavnik
ID: 11892172
I know it's more work, but I think it will pay off for you in the long run.

Make a css file that defines your standard styles.
Add the css link tag (as already mentioned) to each page.
Then edit each datagrid and add the new standard classes to the CssClass of each datagrid.
Finally, remove as much extraneous style info as you can from your datagrids.

Make the effort once, and you won't have to worry about it in the future when you need to add datagrids, or change your styles, or whatever.

It's mostly minor routine edits anyway (probably).
0
 
LVL 9

Author Comment

by:crescendo
ID: 11892180
a_ro_no

I know the benefits of using a style sheet. The problem is that the datagrids seem to have been formatted by a team of madmen. They use different style names all over the place. I'm trying to cut down on the work involved to get back to a standard.
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11892659
So in short crescendo without using css, I don't think theres a way to "Globally" format datagrids

Regards,

Aeros
0
 
LVL 9

Author Comment

by:crescendo
ID: 11892722
No way of adding my own style to the built-in auto-format list?
0
 
LVL 3

Accepted Solution

by:
a_ro_no earned 125 total points
ID: 11892727
I 've tried to find a way to add a custom auto format scheme to the visual studio but I didn't find anything, not even relevant Stylesheet files... It's probably an assembly... Weird... I assume that some Visual studio pluggins should have some tools to add a custom scheme...
In windows forms there is a class caled DatagridStyle or so.. but for Web Control nothing.
0
 
LVL 8

Assisted Solution

by:shovavnik
shovavnik earned 125 total points
ID: 11892839
You can inherit your own datagrid which will implement the cssclasses that you want (and ignore the developer-entered cssclasses), and then you'll only need to change the base datagrid definition without touching anything else.

However, this is a pretty ugly solution, with inherent presentation data loss (the developer-entered cssclasses now and in the future), even though it's lets you define your own behavior.

The best way is to just go over them all once and "standardize" them.  Avoid the pitfalls.  Sometimes the better solution requires a bit more effort.
0
 
LVL 9

Author Comment

by:crescendo
ID: 12184240
There wasn't a solution to the question, except an agreement that it can't be done. I'm happy to give the points as a reward for the effort invested, but it's not much use as a PAQ.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Javascript in a user control not working 17 65
what technologies offer Authentication over Web Services? 4 103
ADO.NET ENTITY DATA MODEL 3 30
Runtime Error 2 28
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
A short film showing how OnPage and Connectwise integration works.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now