Hi..
I have the following in my "MyDesigns.css" file -
.table{Border="2"}.table th,
.table td{padding:8px;}
.table th{font-weight:bold;}
-------------
How to call this in GridView controls ??
Eg -
Here, the class ".table th" is used with ".table".
If I want to call this in GridView HeaderStyle CSS Class, how do I call ??
PLease help !
Loading

Anil KumarRank #2,740 · 511 reputationPosted Mar 4, 2015, 12:53 AM EST
Literal cssFile = new Literal() { Text = @"myCss.css) + @""" type=""text/css"" rel=""stylesheet"" />" };
Anil KumarRank #2,740 · 511 reputationPosted Feb 24, 2015, 6:35 AM EST
NitinRank #455 · 5.5K reputationPosted Feb 25, 2015, 3:16 AM EST
CssClass="table"
Riddhi ValechaRank #794 · 2.9K reputationPosted Mar 3, 2015, 2:56 AM EST
My issue is -
I am getting data from database in datatable and I have assigned this datatable to gridview.
i.e.
Grd_User.Datasource = datatable;
Grd_User.Databind();
---
Property Autogeneratecolumns = true.
--------
The css wokrs fine when I write
and
Property Autogeneratecolumns = false.
------------------
But, I do not want to write this
------
For that, I tried doing in RowDataBound Event. But, even that is not working.
----
Any other solution ??
Please help....
Anil KumarRank #2,740 · 511 reputationPosted Mar 3, 2015, 4:22 AM EST
OR Simply
MyGridView.CssClass = "myCssClass";
To help others, Please mark solution as Accepted if it solves the purpose
Riddhi ValechaRank #794 · 2.9K reputationPosted Mar 3, 2015, 8:00 PM EST
My css files (MyCss.css) is in "Styles" Folder in the solution.
How to access that ??
I have given Heading - yellow colour and rest of gridview is simple and plane.
Anil KumarRank #2,740 · 511 reputationPosted Mar 3, 2015, 8:39 PM EST
OR
or rel="stylesheet" type="text/css" href="styles/myCss.css" />
Riddhi ValechaRank #794 · 2.9K reputationPosted Mar 3, 2015, 9:01 PM EST
I have called this is .aspx page.
But, how to apply this in code-behind (.aspx.cs file) in RowDataBound Event !!
I have written the following -
if (e.Row.RowType == DataControlRowType.Header)
{
foreach (TableCell cell2 in e.Row.Cells)
{
cell2.Attributes.Add("class", "Header");
}
}