Remove EmptyDataTemplate border

让人想犯罪 __ 提交于 2020-01-05 08:00:54

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!