GridView.EmptyDataText Eigenschap

Definitie

Hiermee haalt u de tekst op die wordt weergegeven in de lege gegevensrij die wordt weergegeven wanneer een GridView besturingselement is gebonden aan een gegevensbron die geen records bevat.

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

Waarde van eigenschap

De tekst die moet worden weergegeven in de lege gegevensrij. De standaardwaarde is een lege tekenreeks (""), die aangeeft dat deze eigenschap niet is ingesteld.

Voorbeelden

In het volgende voorbeeld ziet u hoe u de EmptyDataText eigenschap gebruikt om de tekst op te geven die moet worden weergegeven in de lege gegevensrij.


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

Opmerkingen

De lege gegevensrij wordt weergegeven in een GridView besturingselement wanneer de gegevensbron die is gebonden aan het besturingselement geen records bevat. Gebruik de EmptyDataText eigenschap om de tekst op te geven die moet worden weergegeven in de lege gegevensrij. Als u de stijl van de lege gegevensrij wilt beheren, gebruikt u de EmptyDataRowStyle eigenschap. U kunt ook uw eigen aangepaste gebruikersinterface (UI) definiƫren voor de lege gegevensrij door de EmptyDataTemplate eigenschap in te stellen in plaats van deze eigenschap.

Note

Als zowel de eigenschappen EmptyDataTemplate als de EmptyDataText eigenschappen zijn ingesteld, heeft de EmptyDataTemplate eigenschap voorrang.

De waarde van deze eigenschap, wanneer deze is ingesteld, kan automatisch worden opgeslagen in een resourcebestand met behulp van een ontwerpprogramma. Zie en Globalisatie en Lokalisatie voor meer informatieLocalizableAttribute.

Van toepassing op

Zie ook