DetailsView.EmptyDataTemplate 속성

정의

레코드가 들어 있지 않은 데이터 소스에 DetailsView 컨트롤이 바인딩될 때 렌더링되는 빈 데이터 행에 대한 사용자 정의 내용을 가져오거나 설정합니다.

public:
 virtual property System::Web::UI::ITemplate ^ EmptyDataTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.DetailsView))]
public virtual System.Web.UI.ITemplate EmptyDataTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.DetailsView))>]
member this.EmptyDataTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property EmptyDataTemplate As ITemplate

속성 값

빈 데이터 행에 대한 사용자 지정 콘텐츠가 들어 있는 ITemplate입니다. 기본값은 null로, 이 속성이 설정되지 않았음을 나타냅니다.

특성

예제

다음 코드 예제를 사용 EmptyDataTemplate 하는 방법에 설명 합니다 사용자 지정 빈 데이터 행을 만드는 속성입니다.


<%@ 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>DetailsView EmptyDataTemplate Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>DetailsView EmptyDataTemplate Example</h3>
                
        <asp:detailsview id="StoresDetailView"
          datasourceid="StoresDetailsSqlDataSource"
          autogeneraterows="true" 
          EmptyDataText="No records." 
          runat="server">
               
          <emptydatarowstyle backcolor="Navy"
            forecolor="Red"/>
            
          <emptydatatemplate>
          
            <table width="100%">
            
              <tr>
                <td>
                  <asp:Image id="NoRecordsImage"
                    AlternateText='No records' 
                    imageurl="~\images\NoRecords.jpg"
                    runat="server"/> 
                </td>
                <td>
                  <asp:Label id="NoRecordsMessageLabel"
                    forecolor="Red"
                    text="No Records."
                    runat="server"/> 
                </td>
              </tr>
            
            </table>
          
          </emptydatatemplate> 
                    
        </asp:detailsview>
            
        <!-- This example uses Microsoft SQL Server and connects -->
        <!-- to the Pubs sample database.                        -->
        
        <!-- The select query of the following SqlDataSource     -->
        <!-- control has been intentionally set to return no     --> 
        <!-- results to demonstrate the empty data row.          -->      
        <asp:sqldatasource id="StoresDetailsSqlDataSource"  
          selectcommand="SELECT [stor_id], [stor_name], [stor_address], [city], [state], [zip] FROM [stores] WHERE [state]='FL'"
          connectionstring="server=localhost;database=pubs;integrated security=SSPI"
          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>DetailsView EmptyDataTemplate Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>DetailsView EmptyDataTemplate Example</h3>
                
        <asp:detailsview id="StoresDetailView"
          datasourceid="StoresDetailsSqlDataSource"
          autogeneraterows="true" 
          EmptyDataText="No records." 
          runat="server">
               
          <emptydatarowstyle backcolor="Navy"
            forecolor="Red"/>
            
          <emptydatatemplate>
          
            <table width="100%">
            
              <tr>
                <td>
                  <asp:Image id="NoRecordsImage"
                    AlternateText='No Records' 
                    imageurl="~\images\NoRecords.jpg"
                    runat="server"/> 
                </td>
                <td>
                  <asp:Label id="NoRecordsMessageLabel"
                    forecolor="Red"
                    text="No records."
                    runat="server"/> 
                </td>
              </tr>
            
            </table>
          
          </emptydatatemplate> 
                    
        </asp:detailsview>
            
        <!-- This example uses Microsoft SQL Server and connects -->
        <!-- to the Pubs sample database.                        -->
        
        <!-- The select query of the following SqlDataSource     -->
        <!-- control has been intentionally set to return no     --> 
        <!-- results to demonstrate the empty data row.          -->      
        <asp:sqldatasource id="StoresDetailsSqlDataSource"  
          selectcommand="SELECT [stor_id], [stor_name], [stor_address], [city], [state], [zip] FROM [stores] WHERE [state]='FL'"
          connectionstring="server=localhost;database=pubs;integrated security=SSPI"
          runat="server">
        </asp:sqldatasource>
            
      </form>
  </body>
</html>

설명

컨트롤에 바인딩된 데이터 원본에 DetailsView 레코드가 없는 경우 빈 데이터 행이 컨트롤에 표시됩니다. 속성을 사용하여 빈 데이터 행에 대한 사용자 지정 UI(사용자 인터페이스)를 정의할 EmptyDataTemplate 수 있습니다. null 행에 대한 사용자 지정 템플릿을 지정하려면 먼저 컨트롤의 여는 태그와 닫는 태그 사이에 태그를 DetailsView 배치 <EmptyDataTemplate> 합니다. 다음 태그와 닫는 사이 템플릿의 콘텐츠를 나열할 수 있습니다 <EmptyDataTemplate> 태그입니다. 빈 데이터 행의 스타일을 제어하려면 속성을 사용합니다 EmptyDataRowStyle . 또는 이 속성 대신 속성을 설정하여 빈 데이터 행에 기본 제공 UI를 EmptyDataText 사용할 수 있습니다.

참고

모두를 EmptyDataTextEmptyDataTemplate 속성을 설정 합니다 EmptyDataTemplate 속성이 우선 합니다.

적용 대상

추가 정보