ListViewDeletedEventArgs.Exception 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
삭제 작업 중에 발생한 예외(있을 경우)를 가져옵니다.
public:
property Exception ^ Exception { Exception ^ get(); };
public Exception Exception { get; }
member this.Exception : Exception
Public ReadOnly Property Exception As Exception
속성 값
삭제 작업 중에 발생한 예외(있을 경우)이거나, 예외가 발생하지 않은 경우에는 null
입니다.
예제
다음 예제에서는 사용 하는 방법의 Exception 삭제 작업 중에 예외가 발생 했는지 여부를 결정 하는 속성입니다.
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load()
{
Message.Text = String.Empty;
}
void ContactsListView_ItemDeleted(Object sender, ListViewDeletedEventArgs e)
{
// Determine whether an exception occurred during the delete operation.
if (e.Exception == null)
{
// Ensure that a record was deleted.
if (e.AffectedRows > 0)
{
Message.Text = e.AffectedRows + " item(s) deleted successfully.";
}
else
{
Message.Text = "No item was deleted.";
}
}
else
{
// Insert the code to handle the exception here.
// Indicate that the exception has been handled.
e.ExceptionHandled = true;
Message.Text = "An error occurred during the delete operation.";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ListViewDeletedEventArgs Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListViewDeletedEventArgs Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
DataKeyNames="ContactID"
OnItemDeleted="ContactsListView_ItemDeleted"
runat="server">
<LayoutTemplate>
<table cellpadding="2" runat="server" id="tblContacts" width="640px">
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="PeopleDataPager" PageSize="12">
<Fields>
<asp:NextPreviousPagerField
ShowFirstPageButton="true" ShowLastPageButton="true"
FirstPageText="|<< " LastPageText=" >>|"
NextPageText=" > " PreviousPageText=" < " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td valign="top">
<asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
<asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
</td>
<td>
<asp:Label ID="EmailLabel" runat="server" Text='<%#Eval("EmailAddress") %>' />
</td>
<td>
<asp:LinkButton ID="DeleteButton" runat="server"
CommandName="Delete"
Text="Delete"
OnClientClick="return confirm('Are you sure?');" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName], [EmailAddress]
FROM Person.Contact"
DeleteCommand="DELETE FROM Person.Contact WHERE [ContactID] = @ContactID">
<DeleteParameters>
<asp:Parameter Name="ContactID" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load()
Message.Text = String.Empty
End Sub
Sub ContactsListView_ItemDeleted(sender As Object, e As ListViewDeletedEventArgs)
' Determine whether an exception occurred during the delete operation.
If e.Exception Is Nothing Then
' Ensure that a record was deleted.
If e.AffectedRows > 0 Then
Message.Text = e.AffectedRows.ToString() & _
" item(s) deleted successfully."
Else
Message.Text = "No item was deleted."
End If
Else
' Insert the code to handle the exception here.
' Indicate that the exception has been handled.
e.ExceptionHandled = true
Message.Text = "An error occurred during the delete operation."
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ListViewDeletedEventArgs Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListViewDeletedEventArgs Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
DataKeyNames="ContactID"
OnItemDeleted="ContactsListView_ItemDeleted"
runat="server">
<LayoutTemplate>
<table cellpadding="2" runat="server" id="tblContacts" width="640px">
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="PeopleDataPager" PageSize="12">
<Fields>
<asp:NextPreviousPagerField
ShowFirstPageButton="true" ShowLastPageButton="true"
FirstPageText="|<< " LastPageText=" >>|"
NextPageText=" > " PreviousPageText=" < " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td valign="top">
<asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
<asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
</td>
<td>
<asp:Label ID="EmailLabel" runat="server" Text='<%#Eval("EmailAddress") %>' />
</td>
<td>
<asp:LinkButton ID="DeleteButton" runat="server"
CommandName="Delete"
Text="Delete"
OnClientClick="return confirm('Are you sure?');" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName], [EmailAddress]
FROM Person.Contact"
DeleteCommand="DELETE FROM Person.Contact WHERE [ContactID] = @ContactID">
<DeleteParameters>
<asp:Parameter Name="ContactID" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
설명
사용 된 Exception 있는 경우 삭제 작업 중에 발생 하는 예외를 가져올 속성입니다. 발생한 예외가 없으면 이 속성은 null
을 반환합니다.
참고
예외가 발생 한 이벤트 처리기를 설정에 예외를 처리 하는 경우는 ExceptionHandled 속성을 true
입니다. 이 고, 그렇지는 ListView 컨트롤이 다시 예외를 throw 합니다.
적용 대상
추가 정보
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET