BoundField.NullDisplayText 속성

정의

필드 값이 null인 경우 해당 필드에 대해 표시되는 캡션을 가져오거나 설정합니다.

public:
 virtual property System::String ^ NullDisplayText { System::String ^ get(); void set(System::String ^ value); };
public virtual string NullDisplayText { get; set; }
member this.NullDisplayText : string with get, set
Public Overridable Property NullDisplayText As String

속성 값

String

필드 값이 null인 경우 해당 필드에 대해 표시되는 캡션입니다. 기본값은 빈 문자열("")로, 이 속성이 설정되어 있지 않음을 나타냅니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 NullDisplayText 속성을 통해 사용자 지정 필드를 null 값에 대해 표시할 캡션을 지정 합니다.


<%@ 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>BoundField NullDisplayText Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>BoundField NullDisplayText Example</h3>

      <asp:gridview id="DiscountsGridView" 
        datasourceid="DiscountsSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="discounttype"
            nulldisplaytext="No Data"
            headertext="Discount Type"/>
                  
          <asp:boundfield datafield="stor_id"
            nulldisplaytext="No Data"
            headertext="Store ID"/> 
                    
          <asp:boundfield datafield="lowqty"
            nulldisplaytext="No Data"
            headertext="Low Quantity"/>
                    
          <asp:boundfield datafield="highqty"
            nulldisplaytext="No Data"
            headertext="High Quantity"/>
                    
          <asp:boundfield datafield="discount"
            nulldisplaytext="No Data"
            dataformatstring="{0:F4}%" 
            itemstyle-horizontalalign="Right" 
            headertext="Discount"/>     
                
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Pubs sample database.                        -->
      <asp:sqldatasource id="DiscountsSqlDataSource"  
        selectcommand="SELECT [discounttype], [stor_id], [lowqty], [highqty], [discount] FROM [discounts]"
        connectionstring="<%$ ConnectionStrings:PubsConnectionString%>"
        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>BoundField NullDisplayText Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>BoundField NullDisplayText Example</h3>

      <asp:gridview id="DiscountsGridView" 
        datasourceid="DiscountsSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="discounttype"
            nulldisplaytext="No Data"
            headertext="Discount Type"/>
                  
          <asp:boundfield datafield="stor_id"
            nulldisplaytext="No Data"
            headertext="Store ID"/> 
                    
          <asp:boundfield datafield="lowqty"
            nulldisplaytext="No Data"
            headertext="Low Quantity"/>
                    
          <asp:boundfield datafield="highqty"
            nulldisplaytext="No Data"
            headertext="High Quantity"/>
                    
          <asp:boundfield datafield="discount"
            nulldisplaytext="No Data"
            dataformatstring="{0:F4}%" 
            itemstyle-horizontalalign="Right" 
            headertext="Discount"/>     
                
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Pubs sample database.                        -->
      <asp:sqldatasource id="DiscountsSqlDataSource"  
        selectcommand="SELECT [discounttype], [stor_id], [lowqty], [highqty], [discount] FROM [discounts]"
        connectionstring="<%$ ConnectionStrings:PubsConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

설명

경우에 따라 필드 값을 데이터 원본에 null로 저장 됩니다. 사용자 지정 설정 하 여 null 값이 있는 필드에 대해 표시할 캡션을 지정할 수 있습니다는 NullDisplayText 속성입니다. Null 필드 값에 빈 문자열로 표시 되는이 속성을 설정 하지 않으면 (""). 레코드 값을 입력할 경우 데이터 바인딩된 컨트롤에서 삽입 하거나 업데이트할이 속성으로 지정이 빈 문자열) (제외 데이터 바인딩된 컨트롤에서 필드에 대 한 데이터 소스의 값은 null로 자동으로 변환 합니다.

참고

빈 문자열 필드 값을 null 값을 변환 하려면 설정 합니다 ConvertEmptyStringToNull 속성을 true입니다.

적용 대상

추가 정보