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

Dim instance As BoundField Dim value As Boolean value = instance.ConvertEmptyStringToNull instance.ConvertEmptyStringToNull = value
/** @property */ public boolean get_ConvertEmptyStringToNull () /** @property */ public void set_ConvertEmptyStringToNull (boolean value)
public function get ConvertEmptyStringToNull () : boolean public function set ConvertEmptyStringToNull (value : boolean)
空の文字列値を null 値に自動的に変換する場合は true。それ以外の場合は false。既定値は true です。

ユーザーがレコードを更新または挿入するときに、フィールド値として空の文字列を入力する場合があります。データ ソースでデータ フィールドを更新するときに、空の文字列値を null に自動的に変換するかどうかを指定するには、ConvertEmptyStringToNull プロパティを使用します。
![]() |
---|
既定では、BoundField オブジェクトは空の文字列として null 値を表示します。別の値を表示するには、NullDisplayText プロパティを設定します。 |

ConvertEmptyStringToNull プロパティを使用して、空の文字列 ("") フィールド値を null に自動的に変換するコード例を次に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>BoundField Example</h3> <!-- The GridView control automatically sets the columns --> <!-- specified in the datakeynames property as read-only. --> <!-- No input controls are rendered for these columns in --> <!-- edit mode. --> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" autogenerateeditbutton="true" datakeynames="CustomerID" allowpaging="true" runat="server"> <columns> <asp:boundfield datafield="CustomerID" readonly="true" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" convertemptystringtonull="true" headertext="Customer Name"/> <asp:boundfield datafield="Address" convertemptystringtonull="true" headertext="Address"/> <asp:boundfield datafield="City" convertemptystringtonull="true" headertext="City"/> <asp:boundfield datafield="PostalCode" convertemptystringtonull="true" headertext="ZIP Code"/> <asp:boundfield datafield="Country" convertemptystringtonull="true" headertext="Country"/> </columns> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" updatecommand="Update Customers Set CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country Where (CustomerID = @CustomerID)" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>BoundField Example</h3> <!-- The GridView control automatically sets the columns --> <!-- specified in the datakeynames property as read-only. --> <!-- No input controls are rendered for these columns in --> <!-- edit mode. --> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" autogenerateeditbutton="true" datakeynames="CustomerID" allowpaging="true" runat="server"> <columns> <asp:boundfield datafield="CustomerID" readonly="true" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" convertemptystringtonull="true" headertext="Customer Name"/> <asp:boundfield datafield="Address" convertemptystringtonull="true" headertext="Address"/> <asp:boundfield datafield="City" convertemptystringtonull="true" headertext="City"/> <asp:boundfield datafield="PostalCode" convertemptystringtonull="true" headertext="ZIP Code"/> <asp:boundfield datafield="Country" convertemptystringtonull="true" headertext="Country"/> </columns> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" updatecommand="Update Customers Set CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country Where (CustomerID = @CustomerID)" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 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.ConvertEmptyStringToNull プロパティを検索する場合は、下記のリンクをクリックしてください。

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