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>

 

posted @ 2009-04-17 11:34  minmin8110  阅读(398)  评论(0)    收藏  举报