Share via


GridView.EmptyDataText Özellik

Tanım

Bir denetim kayıt içermeyen bir GridView veri kaynağına bağlı olduğunda işlenen boş veri satırında görüntülenecek metni alır veya ayarlar.

public:
 virtual property System::String ^ EmptyDataText { System::String ^ get(); void set(System::String ^ value); };
public virtual string EmptyDataText { get; set; }
member this.EmptyDataText : string with get, set
Public Overridable Property EmptyDataText As String

Özellik Değeri

Boş veri satırında görüntülenecek metin. Varsayılan, bu özelliğin ayarlanmadığını gösteren boş bir dizedir ("").

Örnekler

Aşağıdaki örnek, özelliğinin EmptyDataText boş veri satırında görüntülenecek metni belirtmek için nasıl kullanılacağını 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>GridView EmptyDataText Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView EmptyDataText Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        emptydatatext="No data in the data source."
        runat="server">
        
        <emptydatarowstyle backcolor="LightBlue"
          forecolor="Red"/>
                
      </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 EmptyDataText Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView EmptyDataText Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        emptydatatext="No data in the data source."
        runat="server">
        
        <emptydatarowstyle backcolor="LightBlue"
          forecolor="Red"/>
                
      </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>

Açıklamalar

Denetime bağlı veri kaynağı herhangi bir kayıt içermediğinde boş veri satırı denetimde GridView görüntülenir. EmptyDataText Boş veri satırında görüntülenecek metni belirtmek için özelliğini kullanın. Boş veri satırının stilini denetlemek için özelliğini kullanın EmptyDataRowStyle . Alternatif olarak, bu özellik yerine özelliğini ayarlayarak EmptyDataTemplate boş veri satırı için kendi özel kullanıcı arabiriminizi (UI) tanımlayabilirsiniz.

Not

Hem hem de EmptyDataTextEmptyDataTemplate özellikleri ayarlanırsa, EmptyDataTemplate özellik öncelikli olur.

Bu özelliğin değeri ayarlandığında, bir tasarımcı aracı kullanılarak otomatik olarak bir kaynak dosyasına kaydedilebilir. Daha fazla bilgi için bkz LocalizableAttribute . ve Genelleştirme ve Yerelleştirme.

Şunlara uygulanır

Ayrıca bkz.