Solved

datagrid css

Posted on 2004-03-23
10
1,024 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need help displaying 2 models in one view in my MVC.Net application with C# code behind 5 51
Windows Media Player 2 26
Hey Audio! 3 30
2 questions 10 25
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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