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

ユーザーが編集操作をキャンセルした結果として ModeChanging イベントが発生したことを示す場合は true。それ以外の場合は false。

FormView コントロールが編集、挿入、および読み取り専用の各モード間の切り替えを行おうとすると、実際にモードが変わる前に ModeChanging イベントが発生します。CancelingEdit プロパティを使用して、ユーザーが編集操作や挿入操作をキャンセルした結果として ModeChanging イベントが発生したかどうかを確認します。たとえば、ユーザーが編集操作をキャンセルしたときに FormView コントロールをリセットできます。

CancelingEdit プロパティを使用して、ユーザーが編集操作をキャンセルした結果としてモード変更が発生したのかどうかを確認する方法を次の例に示します。
<%@ Page language="VB" %> <script runat="server"> Sub EmployeeFormView_ModeChanging(ByVal sender As Object, ByVal e As FormViewModeEventArgs) ' Use the NewMode property to determine the mode to which the ' FormView control is transitioning. Select Case e.NewMode Case FormViewMode.Edit ' Hide the pager row and clear the Label control ' when transitioning to edit mode. EmployeeFormView.AllowPaging = False MessageLabel.Text = "" Case FormViewMode.ReadOnly ' Display the pager row and confirmation message ' when transitioning to edit mode. EmployeeFormView.AllowPaging = True If e.CancelingEdit Then MessageLabel.Text = "Update canceled." Else MessageLabel.Text = "Update completed." End If Case FormViewMode.Insert ' Cancel the mode change if the FormView ' control attempts to transition to insert ' mode. e.Cancel = True Case Else MessageLabel.Text = "Unsupported mode." End Select End Sub </script> <html> <body> <form runat="server"> <h3>FormViewModeEventArgs Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." onmodechanging="EmployeeFormView_ModeChanging" runat="server"> <itemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <%# Eval("FirstName") %> <%# Eval("LastName") %> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <%# Eval("Title") %> </td> </tr> <tr> <td> <b>Hire Date:</b> </td> <td> <%# Eval("HireDate","{0:d}") %> </td> </tr> <tr height="150" valign="top"> <td> <b>Address:</b> </td> <td> <%# Eval("Address") %><br/> <%# Eval("City") %> <%# Eval("Region") %> <%# Eval("PostalCode") %><br/> <%# Eval("Country") %> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="Edit" text="Edit" commandname="Edit" runat="server"/> </td> </tr> </table> </itemtemplate> <edititemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeEditImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameUpdateTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameUpdateTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleUpdateTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td> <b>Hire Date:</b> </td> <td> <asp:textbox id="HireDateUpdateTextBox" text='<%# Bind("HireDate", "{0:d}") %>' runat="server"/> </td> </tr> <tr height="150" valign="top"> <td> <b>Address:</b> </td> <td> <asp:textbox id="AddressUpdateTextBox" text='<%# Bind("Address") %>' runat="server"/> <br/> <asp:textbox id="CityUpdateTextBox" text='<%# Bind("City") %>' runat="server"/> <asp:textbox id="RegionUpdateTextBox" text='<%# Bind("Region") %>' width="40" runat="server"/> <asp:textbox id="PostalCodeUpdateTextBox" text='<%# Bind("PostalCode") %>' width="60" runat="server"/> <br/> <asp:textbox id="CountryUpdateTextBox" text='<%# Bind("Country") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="UpdateButton" text="Update" commandname="Update" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </edititemtemplate> </asp:formview> <br/><br/> <asp:label id="MessageLabel" forecolor="Red" runat="server"/> <!-- 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="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [Address], [City], [Region], [PostalCode], [Country], [HireDate], [PhotoPath] From [Employees]" updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title, [Address]=@Address, [City]=@City, [Region]=@Region, [PostalCode]=@PostalCode, [Country]=@Country Where [EmployeeID]=@EmployeeID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void EmployeeFormView_ModeChanging(Object sender, FormViewModeEventArgs e) { // Use the NewMode property to determine the mode to which the // FormView control is transitioning. switch (e.NewMode) { case FormViewMode.Edit: // Hide the pager row and clear the Label control // when transitioning to edit mode. EmployeeFormView.AllowPaging = false; MessageLabel.Text = ""; break; case FormViewMode.ReadOnly: // Display the pager row and confirmation message // when transitioning to edit mode. EmployeeFormView.AllowPaging = true; if (e.CancelingEdit) { MessageLabel.Text = "Update canceled."; } else { MessageLabel.Text = "Update completed."; } break; case FormViewMode.Insert: // Cancel the mode change if the FormView // control attempts to transition to insert // mode. e.Cancel = true; break; default: MessageLabel.Text = "Unsupported mode."; break; } } </script> <html> <body> <form runat="server"> <h3>FormViewModeEventArgs Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." onmodechanging="EmployeeFormView_ModeChanging" runat="server"> <itemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <%# Eval("FirstName") %> <%# Eval("LastName") %> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <%# Eval("Title") %> </td> </tr> <tr> <td> <b>Hire Date:</b> </td> <td> <%# Eval("HireDate","{0:d}") %> </td> </tr> <tr height="150" valign="top"> <td> <b>Address:</b> </td> <td> <%# Eval("Address") %><br/> <%# Eval("City") %> <%# Eval("Region") %> <%# Eval("PostalCode") %><br/> <%# Eval("Country") %> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="Edit" text="Edit" commandname="Edit" runat="server"/> </td> </tr> </table> </itemtemplate> <edititemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeEditImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameUpdateTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameUpdateTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleUpdateTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td> <b>Hire Date:</b> </td> <td> <asp:textbox id="HireDateUpdateTextBox" text='<%# Bind("HireDate", "{0:d}") %>' runat="server"/> </td> </tr> <tr height="150" valign="top"> <td> <b>Address:</b> </td> <td> <asp:textbox id="AddressUpdateTextBox" text='<%# Bind("Address") %>' runat="server"/> <br/> <asp:textbox id="CityUpdateTextBox" text='<%# Bind("City") %>' runat="server"/> <asp:textbox id="RegionUpdateTextBox" text='<%# Bind("Region") %>' width="40" runat="server"/> <asp:textbox id="PostalCodeUpdateTextBox" text='<%# Bind("PostalCode") %>' width="60" runat="server"/> <br/> <asp:textbox id="CountryUpdateTextBox" text='<%# Bind("Country") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="UpdateButton" text="Update" commandname="Update" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </edititemtemplate> </asp:formview> <br/><br/> <asp:label id="MessageLabel" forecolor="Red" runat="server"/> <!-- 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="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [Address], [City], [Region], [PostalCode], [Country], [HireDate], [PhotoPath] From [Employees]" updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title, [Address]=@Address, [City]=@City, [Region]=@Region, [PostalCode]=@PostalCode, [Country]=@Country Where [EmployeeID]=@EmployeeID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </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に収録されているすべての辞書からFormViewModeEventArgs.CancelingEdit プロパティを検索する場合は、下記のリンクをクリックしてください。

- FormViewModeEventArgs.CancelingEdit プロパティのページへのリンク