Solved

datagrid css

Posted on 2004-03-23
10
1,027 Views
Last Modified: 2008-01-09
on a dynamically created datagrid, how do you add programatically css to the Main TR and TD of the datagrid

OMSmartGrid.HeaderStyle  ?
0
Comment
Question by:alain123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 1

Author Comment

by:alain123
ID: 10661624
i meant to the header of the datagrid
0
 
LVL 1

Expert Comment

by:rlawley
ID: 10661879
Yes, you use DataGrid.HeaderStyle.  You can assign it a CssClass using MyDataGrid.HeaderStyle.CssClass, or you can set things separately, e.g. MyDataGrid.HeaderStyle.BorderWidth
0
 
LVL 1

Author Comment

by:alain123
ID: 10662818
i'm really looking to assign css classes to the main TR and TD of the datagrid
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 1

Accepted Solution

by:
rlawley earned 500 total points
ID: 10662873
MyDataGrid.HeaderStyle.CssClass does assign a CSS class to the TR in the header row.  If you need to be able to access the TD inside this then I suggest you use a css selector.  For example, if you have a css class called headerrow, you can assign this to the TR of the header line using:

MyDataGrid.HeaderStyle.CssClass = "headerrow";

Then in css you can just do

TR.headerrow {
  /* Styles to apply to the TR */
}

TR.headerrow TD {
  /* Styles to apply to the TD within the header TR */
}

If this is not what you want to do then I have misunderstood you.
0
 
LVL 1

Author Comment

by:alain123
ID: 10662941
thank you, that's a solution to the problem.. too bad it cannot be on the c# code
0
 
LVL 1

Author Comment

by:alain123
ID: 10663032


by any chance do you know how to set only the outside border?

Grid.BorderStyle = System.Web.UI.WebControls.BorderStyle.Outset;  i'm trying something like that but doesn't work..
0
 
LVL 1

Expert Comment

by:rlawley
ID: 10663098
You don't have to use CSS, but it's easier as it removes some of the formatting from the code.  You can still use MyGrid.HeaderStyle.ForeColor etc.  I'm not sure if you can get at the TDs directly but I don't know if you need this.

Regarding the BorderStyle, that should work fine.  Be careful you aren't overriding it somewhere.  I couldn't get BorderStyle to make much difference, but BorderColor worked fine.
0
 
LVL 1

Author Comment

by:alain123
ID: 10663138
ok thank you, i'll keep plaing with it..  still wasn't able to get the TD's on the c# code.. as for the border.. it's putting borders inside the grid too, not only outside as i wanted.. thanks
0
 
LVL 1

Expert Comment

by:rlawley
ID: 10663192
Well, if all else fails, this will put a border round the outside...

Grid.GridLines = GridLines.None;
Grid.Style.Add("border", "solid 1px black");
0
 
LVL 1

Author Comment

by:alain123
ID: 10667898
perfect thank you!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 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