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

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

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

CancelingEdit プロパティを使用して、ユーザーが編集操作をキャンセルした結果としてモード変更が発生したのかどうかを確認する方法のコード例を次に示します。
<%@ Page language="VB" autoeventwireup="false" %> <script runat="server"> Sub CustomerDetailsView_ModeChanging(ByVal sender As Object, ByVal e As DetailsViewModeEventArgs) Handles CustomerDetailsView.ModeChanging ' Use the NewMode property to determine the mode to which the ' DetailsView control is transitioning. Select Case e.NewMode Case DetailsViewMode.Edit ' Hide the pager row and clear the Label control ' when transitioning to edit mode. CustomerDetailsView.AllowPaging = False MessageLabel.Text = "" Case DetailsViewMode.ReadOnly ' Display the pager row and confirmation message ' when transitioning to edit mode. CustomerDetailsView.AllowPaging = True If e.CancelingEdit Then MessageLabel.Text = "Update canceled." Else MessageLabel.Text = "Update completed." End If Case DetailsViewMode.Insert ' Cancel the mode change if the DetailsView ' 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>DetailsViewModeEventArgs Example</h3> <asp:detailsview id="CustomerDetailsView" datasourceid="DetailsViewSource" datakeynames="CustomerID" autogeneraterows="true" autogenerateeditbutton="true" allowpaging="true" runat="server"> </asp:detailsview> <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="DetailsViewSource" 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"/> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void CustomerDetailsView_ModeChanging(Object sender, DetailsViewModeEventArgs e) { // Use the NewMode property to determine the mode to which the // DetailsView control is transitioning. switch (e.NewMode) { case DetailsViewMode.Edit: // Hide the pager row and clear the Label control // when transitioning to edit mode. CustomerDetailsView.AllowPaging = false; MessageLabel.Text = ""; break; case DetailsViewMode.ReadOnly: // Display the pager row and confirmation message // when transitioning to edit mode. CustomerDetailsView.AllowPaging = true; if (e.CancelingEdit) { MessageLabel.Text = "Update canceled."; } else { MessageLabel.Text = "Update completed."; } break; case DetailsViewMode.Insert: // Cancel the mode change if the DetailsView // control attempts to transition to insert // mode. e.Cancel = true; break; default: MessageLabel.Text = "Unsupported mode."; break; } } </script> <html> <body> <form runat="server"> <h3>DetailsViewModeEventArgs Example</h3> <asp:detailsview id="CustomerDetailsView" datasourceid="DetailsViewSource" datakeynames="CustomerID" autogeneraterows="true" autogenerateeditbutton="true" allowpaging="true" onmodechanging="CustomerDetailsView_ModeChanging" runat="server"> </asp:detailsview> <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="DetailsViewSource" 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"/> </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に収録されているすべての辞書からDetailsViewModeEventArgs.CancelingEdit プロパティを検索する場合は、下記のリンクをクリックしてください。

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