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

Dim instance As CommandField Dim value As Boolean value = instance.CausesValidation instance.CausesValidation = value
public: virtual property bool CausesValidation { bool get () override; void set (bool value) override; }
/** @property */ public boolean get_CausesValidation () /** @property */ public void set_CausesValidation (boolean value)
public override function get CausesValidation () : boolean public override function set CausesValidation (value : boolean)
ユーザーが CommandField フィールドのボタンをクリックしたときに検証を実行する場合は true。それ以外の場合は false。既定値は true です。

CausesValidation プロパティを使用して、CommandField フィールドのボタンがクリックされたときに検証を実行するかどうかを指定します。このプロパティが true に設定されている場合、ページのすべての検証コントロールが既定で検証されます。検証を検証コントロールの特定のグループだけに制限するには、検証グループを作成してから ValidationGroup プロパティを検証グループの名前に設定します。検証グループの詳細については、BaseValidator.ValidationGroup のトピックを参照してください。

CausesValidation プロパティを使用して、CommandField フィールドのボタンがクリックされたときに検証を行わないようにする方法を次のコード例に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>CommandField CausesValidation Example</h3> <!-- Normally, the validation controls declared in the --> <!-- EditItemTemplate of each TemplateField field column would --> <!-- prevent the user from leaving a field value empty; however, --> <!-- because the CausesValidation property of the CommandField --> <!-- field column is set to false, validation does not occur when --> <!-- the user clicks a button in the CommandField field column. --> <asp:gridview id="CustomerGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" datakeynames="CustomerID" cellpadding="10" runat="server"> <columns> <asp:commandfield showeditbutton="true" causesvalidation="false" headertext="Edit"/> <asp:boundfield datafield="CustomerID" headertext="Customer ID" readonly="true"/> <asp:templatefield headertext="Company Name" itemstyle-verticalalign="Top"> <itemtemplate> <%#Eval("CompanyName")%> </itemtemplate> <edititemtemplate> <asp:textbox id="CompanyNameTextBox" text='<%#Bind("CompanyName")%>' width="90" runat="server"/> <br/> <asp:requiredfieldvalidator id="CompanyNameRequiredValidator" controltovalidate="CompanyNameTextBox" display="Dynamic" text="Please enter the company name." runat="server"/> </edititemtemplate> </asp:templatefield> <asp:templatefield headertext="Address" itemstyle-verticalalign="Top"> <itemtemplate> <%#Eval("Address")%> </itemtemplate> <edititemtemplate> <asp:textbox id="AddressTextBox" text='<%#Bind("Address")%>' width="90" runat="server"/> <br/> <asp:requiredfieldvalidator id="AddressRequiredValidator" controltovalidate="AddressTextBox" display="Dynamic" text="Please enter the address." runat="server"/> </edititemtemplate> </asp:templatefield> <asp:templatefield headertext="City" itemstyle-verticalalign="Top"> <itemtemplate> <%#Eval("City")%> </itemtemplate> <edititemtemplate> <asp:textbox id="CityTextBox" text='<%#Bind("City")%>' width="90" runat="server"/> <br/> <asp:requiredfieldvalidator id="CityRequiredValidator" controltovalidate="CityTextBox" display="Dynamic" text="Please enter the city." runat="server"/> </edititemtemplate> </asp:templatefield> </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] From [Customers]" updatecommand="Update [Customers] Set [CompanyName]=@CompanyName, [Address]=@Address, [City]=@City Where [CustomerID] = @CustomerID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>CommandField CausesValidation Example</h3> <!-- Normally, the validation controls declared in the --> <!-- EditItemTemplate of each TemplateField field column would --> <!-- prevent the user from leaving a field value empty; however, --> <!-- because the CausesValidation property of the CommandField --> <!-- field column is set to false, validation does not occur when --> <!-- the user clicks a button in the CommandField field column. --> <asp:gridview id="CustomerGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" datakeynames="CustomerID" cellpadding="10" runat="server"> <columns> <asp:commandfield showeditbutton="true" causesvalidation="false" headertext="Edit"/> <asp:boundfield datafield="CustomerID" headertext="Customer ID" readonly="true"/> <asp:templatefield headertext="Company Name" itemstyle-verticalalign="Top"> <itemtemplate> <%#Eval("CompanyName")%> </itemtemplate> <edititemtemplate> <asp:textbox id="CompanyNameTextBox" text='<%#Bind("CompanyName")%>' width="90" runat="server"/> <br/> <asp:requiredfieldvalidator id="CompanyNameRequiredValidator" controltovalidate="CompanyNameTextBox" display="Dynamic" text="Please enter the company name." runat="server"/> </edititemtemplate> </asp:templatefield> <asp:templatefield headertext="Address" itemstyle-verticalalign="Top"> <itemtemplate> <%#Eval("Address")%> </itemtemplate> <edititemtemplate> <asp:textbox id="AddressTextBox" text='<%#Bind("Address")%>' width="90" runat="server"/> <br/> <asp:requiredfieldvalidator id="AddressRequiredValidator" controltovalidate="AddressTextBox" display="Dynamic" text="Please enter the address." runat="server"/> </edititemtemplate> </asp:templatefield> <asp:templatefield headertext="City" itemstyle-verticalalign="Top"> <itemtemplate> <%#Eval("City")%> </itemtemplate> <edititemtemplate> <asp:textbox id="CityTextBox" text='<%#Bind("City")%>' width="90" runat="server"/> <br/> <asp:requiredfieldvalidator id="CityRequiredValidator" controltovalidate="CityTextBox" display="Dynamic" text="Please enter the city." runat="server"/> </edititemtemplate> </asp:templatefield> </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] From [Customers]" updatecommand="Update [Customers] Set [CompanyName]=@CompanyName, [Address]=@Address, [City]=@City 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に収録されているすべての辞書からCommandField.CausesValidation プロパティを検索する場合は、下記のリンクをクリックしてください。

- CommandField.CausesValidation プロパティのページへのリンク