Work with GridView Header border through CSS
Posted: September 14, 2007 Filed under: ASP.NET 2 Leave a comment1. Define the border style for the TH element which represents the header for the Gridview:
<style type="text/css">.myheader th { background-color:Blue; border-color:Black; border-style:solid; border-width:2; color:White; }
</style>
2. And overide in the GridView’s PreRender event to replace the default style="border-collapse:collapse;"protected void GridView1_OnPreRender(object sender, EventArgs e)
{GridView1.Style[
"border-collapse"] = "seperate";
}
3. in your gridview, set HeaderStyle-CssClass="myheader" .