DetailsView.EmptyDataRowStyle 属性

定义

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置在绑定到 DetailsView 控件的数据源不包含任何记录时所显示的空数据行的外观。Gets a reference to the TableItemStyle object that allows you to set the appearance of the empty data row displayed when the data source bound to a DetailsView control does not contain any records.

public:
 property System::Web::UI::WebControls::TableItemStyle ^ EmptyDataRowStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle EmptyDataRowStyle { get; }
member this.EmptyDataRowStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property EmptyDataRowStyle As TableItemStyle

属性值

一个对 TableItemStyle 的引用,使用该对象可以设置空数据行的外观。A reference to the TableItemStyle that allows you to set the appearance of the empty data row.

属性

示例

下面的代码示例演示如何使用EmptyDataRowStyle属性为空数据行指定字体和样式设置。The following code example demonstrates how to use the EmptyDataRowStyle property to specify the font and style settings for the empty data row.


<%@ 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>DetailsView EmptyDataText Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>DetailsView EmptyDataText Example</h3>
                
        <asp:detailsview id="StoresDetailView"
          datasourceid="StoresDetailsSqlDataSource"
          autogeneraterows="true" 
          EmptyDataText="No records." 
          runat="server">
               
          <emptydatarowstyle backcolor="Navy"
            forecolor="Red"/> 
                    
        </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="<%$ 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>DetailsView EmptyDataText Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>DetailsView EmptyDataText Example</h3>
                
        <asp:detailsview id="StoresDetailView"
          datasourceid="StoresDetailsSqlDataSource"
          autogeneraterows="true" 
          EmptyDataText="No records." 
          runat="server">
               
          <emptydatarowstyle backcolor="Navy"
            forecolor="Red"/> 
                    
        </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="<%$ ConnectionStrings:NorthWindConnectionString%>"
          runat="server">
        </asp:sqldatasource>
            
      </form>
  </body>
</html>

注解

使用属性可控制DetailsView控件中的空数据行的外观。 EmptyDataRowStyleUse the EmptyDataRowStyle property to control the appearance of the empty data row in a DetailsView control. 当绑定到控件的数据源不包含任何记录时, 将显示空数据行。The empty data row is displayed when the data source that is bound to the control does not contain any records. 此属性是只读的;但是, 您可以设置它返回的TableItemStyle对象的属性。This property is read-only; however, you can set the properties of the TableItemStyle object it returns. Property-Subproperty可以在窗体中以声明方式设置这些属性, 其中Subproperty TableItemStyle是对象的一个属性 (例如EmptyDataRowStyle-ForeColor)。The properties can be set declaratively in the form Property-Subproperty, where Subproperty is a property of the TableItemStyle object (for example, EmptyDataRowStyle-ForeColor). 还可以在窗体Property.Subproperty中以编程方式设置属性 ( EmptyDataRowStyle.ForeColor例如)。The properties can also be set programmatically in the form Property.Subproperty (for example, EmptyDataRowStyle.ForeColor). 常见设置通常包括自定义背景色、前景色和字体属性。Common settings usually include a custom background color, foreground color, and font properties.

适用于

另请参阅