GridView.EmptyDataText Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Denetim herhangi bir GridView kayıt içermeyen bir 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, boş veri satırında görüntülenecek metni belirtmek için özelliğinin nasıl kullanılacağını EmptyDataText 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.
Uyarı
hem ve EmptyDataTextEmptyDataTemplate özellikleri ayarlanırsa, EmptyDataTemplate özelliği öncelikli olur.
Bu özelliğin değeri ayarlandığında, 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.