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

Dim instance As BoundField Dim value As String value = instance.NullDisplayText instance.NullDisplayText = value
/** @property */ public String get_NullDisplayText () /** @property */ public void set_NullDisplayText (String value)
public function get NullDisplayText () : String public function set NullDisplayText (value : String)
フィールド値が null の場合にフィールドに表示するキャプション。既定値は空の文字列 ("") です。このプロパティが設定されていないことを示します。

データ ソースではフィールド値が null として格納されている場合があります。null 値を格納しているフィールドに対して表示するカスタムのキャプションを指定するには、NullDisplayText プロパティを設定します。このプロパティを設定しない場合、null フィールド値が空の文字列 ("") として表示されます。データ バインド コントロールでレコードを更新または挿入するときに、ユーザーがこのプロパティで指定される値 (空の文字列以外) をデータ バインド コントロール内のフィールドに入力すると、この値はデータ ソースで自動的に null に変換されます。
![]() |
---|
空の文字列フィールド値を null 値に変換するには、ConvertEmptyStringToNull プロパティを true に設定します。 |

NullDisplayText プロパティを使用して、null フィールド値に対して表示するカスタムのキャプションを指定するコード例を次に示します。
<%@ Page language="VB" %> <html> <body> <form 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="C#" %> <html> <body> <form 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>

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

- BoundField.NullDisplayText プロパティのページへのリンク