GridView.EmptyDataRowStyle 属性
下面的代码示例演示如何通过声明方式设置 EmptyDataRowStyle 属性来为空行指定淡蓝色背景和红色字体
<%@ Page language="C#" %>
<html>
<body>
<form runat="server">
<h3>GridView EmptyDataTemplate Example</h3>
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSqlDataSource"
autogeneratecolumns="true"
runat="server">
<emptydatarowstyle backcolor="LightBlue"
forecolor="Red"/>
<emptydatatemplate>
<asp:image id="NoDataImage"
imageurl="~/images/Image.jpg"
runat="server"/>
No Data Found.
</emptydatatemplate>
</asp:gridview>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. The following query -->
<!-- returns an empty data source to demonstrate the -->
<!-- empty row. -->
<asp:sqldatasource id="CustomersSqlDataSource"
selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers] Where CustomerID='NoID'"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server">
</asp:sqldatasource>
</form>
</body>
</html>

浙公网安备 33010602011771号