GridView.EmptyDataRowStyle 속성

정의

레코드가 들어 있지 않은 데이터 소스에 TableItemStyle 컨트롤이 바인딩될 때 렌더링되는 빈 데이터 행의 모양을 설정하는 데 사용할 수 있는 GridView 개체에 대한 참조를 가져옵니다.

public:
 property System::Web::UI::WebControls::TableItemStyle ^ EmptyDataRowStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle EmptyDataRowStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.EmptyDataRowStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property EmptyDataRowStyle As TableItemStyle

속성 값

null 행의 모양을 설정하는 데 사용할 수 있는 TableItemStyle에 대한 참조입니다.

특성

예제

다음 예제에서는 설정 하는 EmptyDataRowStyle 방법을 보여 줍니다는 속성에 대 한 밝은 파란색 배경 및 null 행에 대 한 빨간색 글꼴을 지정 하는 선언적으로 합니다.


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>GridView EmptyDataTemplate Example</title>
</head>
<body>
    <form id="form1" 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"
            alternatetext="No Image" 
            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>

<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>GridView EmptyDataTemplate Example</title>
</head>
<body>
    <form id="form1" 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"
            alternatetext="No Image" 
            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>

설명

사용 된 EmptyDataRowStyle 속성을 컨트롤에서 null 행의 모양을 제어 합니다 GridView . 컨트롤에 바인딩된 데이터 원본에 레코드가 없는 경우 null 행이 표시됩니다. 이 속성은 읽기 전용입니다. 그러나의 속성을 설정할 수는 TableItemStyle 개체를 반환 합니다. 속성은 다음 메서드 중 하나를 사용하여 선언적으로 설정할 수 있습니다.

  • 형식의 컨트롤의 여는 GridView 태그에 Property-Subproperty특성을 배치합니다. 여기서 Subproperty 는 개체의 TableItemStyle 속성(예: EmptyDataRowStyle-ForeColor)입니다.

  • <EmptyDataRowStyle> 컨트롤의 여는 태그와 닫는 태그 사이에 요소를 중첩합니다GridView.

형식에서 속성을 프로그래밍 방식으로 설정할 수도 있습니다 Property.Subproperty (예를 들어 EmptyDataRowStyle.ForeColor). 일반적인 설정에는 일반적으로 사용자 지정 배경색, 전경색 및 글꼴 속성이 포함됩니다.

적용 대상

추가 정보