dam
dam

Reputation: 171

Remove border for a Gridview EmptyDataTemplate but maintain the borders of a sub-gridview

I have a GridView named gvDomSoilType. When empty, it's EmptyDataTemplate will display a table with an empty row or insert. By default, this table is surrounded by a border. If I set gvDomSoilType's BorderWidth to 0px, this border disappears. However, if the GridView has data, its outer borders are also missing.

I've tried messing with EmptyDataRowStyle but nothing removes the border. The only method is to set the GridView's BorderWidth to 0.

How do I remove the borders only when EmptyDataTemplate is showing but keep them when the GridView has data?

Screenshot

Upvotes: 1

Views: 1562

Answers (1)

Peter Rankin
Peter Rankin

Reputation: 733

I had the same problem. I added this to the GridView HTML:

<EmptyDataRowStyle CssClass="EmptyData" />

And then put this jQuery at the bottom of the page (be sure to include jQuery too):

$(".EmptyData").parents("table").css("border-width", "0px").prop("border", "0");

This removes the border only for the EmptyDataTemplate.

Upvotes: 2

Related Questions