Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
|
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2005, 08:03 AM
Registered User
 
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataGrid printing - CSS settings

I want to print a datagrid in ASPX document and I want that each page would have a datagrid header. How can I solve this problem with CSS?

 
Old October 27th, 2005, 05:31 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

If you've tries to set CSS styles for your DataGrids, you may have run into a problem with sort columns. Sort columns contain DataGridLinkButtons which render as HTML anchor tags. Since these controls are contained within the DataGrid header itself, setting the CssClass for the header won't get the style applied to the anchors. The easy solution is to set the styles directly in the grid at design time, but that means changing the aspx/ascx should a style change be required. It would be better to be able to set the styles in CSS and it can be done with a little ingenuity.

The trick is to use what's called Contextual Selectors and Pseudo-Classes. I'll show a sample that sets a DataGrid's headers to a gray background with white text. The HeaderStyle CssClass of the grid has been set to TaskGrid_Head. Here's the sample and then I'll explain it:

..TaskGrid_Head, TaskGrid_Head td, .TaskGrid_Head a, .TaskGrid_Head a:link, .
TaskGrid_Head a:visited, .TaskGrid_Head a:hover{
   font-weight: bold;
   font-size: 10pt;
   color: #ffffff;
   background-color: #c0c0c0;
}

What this does is to tell all td's and anchors who are contained within elements with a CSS class of TaskGrid_Head to take on the style as defined. The TaskGrid_Head td is an example of such a Contextual Selector.

One more item: To get all the states of an anchor to behave, use the pseudo-classes a:link, a:hover, and a:visited.

www.crmpicco.co.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Settings.settings when assembly is in GAC evandro.paula .NET Framework 2.0 0 September 25th, 2007 09:54 AM
Printing DataGrid Data koneruvijay VS.NET 2002/2003 4 April 10th, 2007 05:58 AM
Datagrid printing Amorous ASP.NET 1.0 and 1.1 Basics 1 April 6th, 2006 12:25 AM
capturing printing settings when printing reports nikolaosk Access VBA 0 February 8th, 2005 04:14 AM
C# DataGrid Printing adwatts C# 2 September 30th, 2004 09:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.