Solved

datagrid css

Posted on 2004-03-23
10
1,022 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
  • 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

20 Experts available now in Live!

Get 1:1 Help Now