GridView.EmptyDataText プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As GridView Dim value As String value = instance.EmptyDataText instance.EmptyDataText = value
[LocalizableAttribute(true)] public: virtual property String^ EmptyDataText { String^ get (); void set (String^ value); }
/** @property */ public String get_EmptyDataText () /** @property */ public void set_EmptyDataText (String value)
空のデータ行に表示されるテキスト。既定値は空の文字列 ("") です。このプロパティが設定されていないことを示します。

コントロールにバインドされているデータ ソースにレコードが格納されていない場合、GridView コントロールに空のデータ行が表示されます。EmptyDataText プロパティを使用して、空のデータ行に表示するテキストを指定します。空のデータ行のスタイルを制御するには、EmptyDataRowStyle プロパティを使用します。また、このプロパティの代わりに EmptyDataTemplate プロパティを設定して、空のデータ行用に独自のカスタム ユーザー インターフェイス (UI) を定義することもできます。
![]() |
---|
EmptyDataText プロパティと EmptyDataTemplate プロパティの両方が設定されている場合は、EmptyDataTemplate プロパティが優先されます。 |
このプロパティの値は、設定時に、デザイナ ツールを使用してリソース ファイルに自動的に保存できます。詳細については、LocalizableAttribute、ASP.NET のグローバリゼーションおよびローカリゼーション の各トピックを参照してください。

EmptyDataText プロパティを使用して、空のデータ行に表示するテキストを指定する方法を次のコード例に示します。
<%@ Page language="VB" %> <html> <body> <form 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="C#" %> <html> <body> <form 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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からGridView.EmptyDataText プロパティを検索する場合は、下記のリンクをクリックしてください。

- GridView.EmptyDataText プロパティのページへのリンク