BoundField.NullDisplayText Özellik

Tanım

Alanın değeri null olduğunda alan için görüntülenen resim yazısını alır veya ayarlar.

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

Özellik Değeri

String

Alanın değeri null olduğunda alan için görüntülenen resim yazısı. Varsayılan değer, bu özelliğin ayarlanmadığını gösteren boş bir dizedir ("").

Örnekler

Aşağıdaki kod örneği, null alan değerleri için görüntülenecek özel bir resim yazısı belirtmek üzere özelliğinin nasıl kullanılacağını NullDisplayText 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>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>

Açıklamalar

Bazen bir alanın değeri veri kaynağında null olarak depolanır. özelliğini ayarlayarak NullDisplayText null değere sahip alanlar için görüntülenecek özel bir resim yazısı belirtebilirsiniz. Bu özellik ayarlanmamışsa, null alan değerleri boş dizeler ("") olarak görüntülenir. Bir kayıt güncelleştirilirken veya veriye bağlı denetime eklendiğinde, kullanıcı veriye bağlı denetimdeki bir alan için bu özellik tarafından belirtilen değeri (boş bir dize dışında) girerse, bu değer otomatik olarak veri kaynağında null değerine dönüştürülür.

Not

Boş bir dize alanı değerini null değere dönüştürmek için özelliğini olarak trueayarlayınConvertEmptyStringToNull.

Şunlara uygulanır

Ayrıca bkz.