DetailsView.EmptyDataTemplate Özellik

Tanım

Denetim herhangi bir kayıt içermeyen bir DetailsView veri kaynağına bağlı olduğunda işlenen boş veri satırı için kullanıcı tanımlı içeriği alır veya ayarlar.

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

Özellik Değeri

ITemplate

ITemplate Boş veri satırı için özel içeriği içeren bir. Varsayılan değer, nullbu özelliğin ayarlanmadığını gösteren değeridir.

Öznitelikler

Örnekler

Aşağıdaki kod örneği, özel boş bir veri satırı oluşturmak için özelliğinin nasıl kullanılacağını EmptyDataTemplate gösterir.


<%@ 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>

Açıklamalar

Denetime bağlı veri kaynağı herhangi bir DetailsView kayıt içermediğinde, boş veri satırı denetimde görüntülenir. özelliğini kullanarak EmptyDataTemplate boş veri satırı için kendi özel kullanıcı arabiriminizi (UI) tanımlayabilirsiniz. Null satır için özel bir şablon belirtmek için, önce etiketleri denetimin açma ve kapatma etiketleri DetailsView arasına yerleştirin<EmptyDataTemplate>. Ardından, şablonun içeriğini açma ve kapatma <EmptyDataTemplate> etiketleri arasında listeleyebilirsiniz. Boş veri satırının stilini denetlemek için özelliğini kullanın EmptyDataRowStyle . Alternatif olarak, bu özellik yerine özelliğini ayarlayarak boş veri satırı için yerleşik kullanıcı arabirimini EmptyDataText kullanabilirsiniz.

Not

Hem hem EmptyDataTemplate de EmptyDataText özellikleri ayarlanırsa, EmptyDataTemplate özelliği öncelikli olur.

Şunlara uygulanır

Ayrıca bkz.