Link to home
Start Free TrialLog in
Avatar of alain123
alain123

asked on

datagrid css

on a dynamically created datagrid, how do you add programatically css to the Main TR and TD of the datagrid

OMSmartGrid.HeaderStyle  ?
Avatar of alain123
alain123

ASKER

i meant to the header of the datagrid
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
i'm really looking to assign css classes to the main TR and TD of the datagrid
ASKER CERTIFIED SOLUTION
Avatar of rlawley
rlawley

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you, that's a solution to the problem.. too bad it cannot be on the c# code


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..
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.
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
Well, if all else fails, this will put a border round the outside...

Grid.GridLines = GridLines.None;
Grid.Style.Add("border", "solid 1px black");
perfect thank you!