该GridView有一个EmptyDataRow模板和样式,只是使用的是:
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSqlDataSource"
autogeneratecolumns="true"
runat="server">
<emptydatarowstyle backcolor="LightBlue"
forecolor="Red"/>
<emptydatatemplate>
<asp:image id="NoDataImage"
imageurl="~/images/Image.jpg"
alternatetext="No Image"
runat="server"/>
No Data Found.
</emptydatatemplate>
</asp:gridview>
Run Code Online (Sandbox Code Playgroud)
来自MSDN GridView.EmptyDataRowStyle属性的示例(自.NET 2.0起可用)