Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

datagrid css

Posted on 2004-03-23
10
Medium Priority
?
1,031 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
Technology Partners: 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!

 
LVL 1

Accepted Solution

by:
rlawley earned 1500 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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!
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

916 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