Jon's Blog

.NET Development & More

GridView EmptyDataTemplate: Get Rid of That Annoying Border!

If you are like me then you may have a CSS table style for your GridView with a specific border.  When you use the the EmptyDataTemplate you may then have a border around your message.  I create a CSS class and then use the EmptyDataRowStyle and set its CssClass.  Note, in the GridView I am also setting the default border to 0.  Example:


table.myGridClass .empty td
border-style: none;
border-width: 0px;
background-color: #ffffdd;



<asp:GridView ID="myGridView" runat="server" CssClass="myGridClass" BorderWidth="0">
<HeaderStyle CssClass="myHeaderStyle" />
<RowStyle CssClass="myRowStyle" />
<EmptyDataRowStyle CssClass="empty" />
<EmptyDataTemplate>Your message here.</EmptyDataTemplate>

Comments (1) -

  • Remco

    11/10/2011 4:30:45 AM |

    I stumbled upon this article and I'n curiuous how did solve is. I thought of the same solution and I was glad I found it here as well. But for some reason I'm not getting the desired result. Could you please post the whole solution? Thanks.

Comments are closed