问题
I have a GridView in ASP.NET with custom CSS styling, including a border. The EmptyItemTemplate has a message: "No results found" but has a border which I want to remove. I know about this code:
<EmptyDataRowStyle BorderWidth="0" />
However, this applies to the row, not the table itself--so the table border remains. I've also tried applying a custom CSS class to the EmptyDataRowStyle, but this applies to the row, not the table itself.
So how do I remove the border on the EmptyDataTemplate?
回答1:
I ended up using jQuery. I added this to the GridView:
<EmptyDataRowStyle CssClass="EmptyData" />
And then added this jQuery at the bottom of the page:
$(".EmptyData").parents("table").css("border-width", "0px").prop("border", "0");
回答2:
Use only CSS
<EmptyDataRowStyle CssClass="EmptyData" />
.EmptyData td {
border-width: 0px !important;
}
回答3:
I ended up solving it by adding GridLines="None":
<asp:DetailsView runat="server" ID="dv" CssClass="noborder" GridLines="None">
CSS:
.noborder { border: none }
来源:https://stackoverflow.com/questions/16242910/remove-emptydatatemplate-border