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

<TemplateContainerAttribute(GetType(DetailsView))> _ Public Overridable Property EmptyDataTemplate As ITemplate
Dim instance As DetailsView Dim value As ITemplate value = instance.EmptyDataTemplate instance.EmptyDataTemplate = value
[TemplateContainerAttribute(typeof(DetailsView))] public virtual ITemplate EmptyDataTemplate { get; set; }
[TemplateContainerAttribute(typeof(DetailsView))] public: virtual property ITemplate^ EmptyDataTemplate { ITemplate^ get (); void set (ITemplate^ value); }
/** @property */ public ITemplate get_EmptyDataTemplate () /** @property */ public void set_EmptyDataTemplate (ITemplate value)
public function get EmptyDataTemplate () : ITemplate public function set EmptyDataTemplate (value : ITemplate)
空のデータ行用のカスタム コンテンツを含んだ System.Web.UI.ITemplate。既定値は null 参照 (Visual Basic では Nothing) で、このプロパティが設定されていないことを示します。

コントロールにバインドされているデータ ソースにレコードが格納されていない場合、DetailsView コントロールに空のデータ行が表示されます。EmptyDataTemplate プロパティを使用して、空のデータ行に独自のカスタム ユーザー インターフェイス (UI) を定義できます。null 行のカスタム テンプレートを指定するには、最初に <EmptyDataTemplate> タグを DetailsView コントロールの開始タグと終了タグの間に配置します。その後、<EmptyDataTemplate> の開始タグと終了タグの間に、テンプレートの内容のリストを記述できます。空のデータ行のスタイルを制御するには、EmptyDataRowStyle プロパティを使用します。また、このプロパティの代わりに EmptyDataText プロパティを設定して、空のデータ行の組み込み UI を使用することもできます。
![]() |
---|
EmptyDataText プロパティと EmptyDataTemplate プロパティの両方が設定されている場合は、EmptyDataTemplate プロパティが優先されます。 |

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

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に収録されているすべての辞書からDetailsView.EmptyDataTemplate プロパティを検索する場合は、下記のリンクをクリックしてください。

- DetailsView.EmptyDataTemplate プロパティのページへのリンク