Set the Line Color Between Rows in an ASP.NET GridView

Have you wondered how to set the color between two rows in an ASP.NET GridView. The GridView control does not provide a direct attribute for setting a color to the lines between two rows. But here’s how to do it using CSS:

<html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<
title>Change Color of Lines</title>
<
style type="text/css">
.gridLines td
{
border-bottom: 1px solid Gray;
}
</style>
</
head>
<
body>
<
form id="form1" runat="server">
<
div>
<
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
GridLines="Horizontal" CssClass="gridLines" DataKeyNames="ID" >
<
Columns>
...
</Columns>
</
asp:GridView>
</
div>
</
form>
</
body>
</
html>

OUTPUT

image






About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

No comments: