ListViewItemEventArgs 클래스

정의

ItemCreatedItemDataBound 이벤트에 대한 데이터를 제공합니다.

public ref class ListViewItemEventArgs : EventArgs
public class ListViewItemEventArgs : EventArgs
type ListViewItemEventArgs = class
    inherit EventArgs
Public Class ListViewItemEventArgs
Inherits EventArgs
상속
ListViewItemEventArgs

예제

다음 예제에서는 사용 하는 방법의 ListViewItemEventArgs 데이터에 바인딩되는 항목의 속성에 액세스 하는 개체입니다.


<%@ 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">

    // <Snippet2>
    protected void ContactsListView_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        Label EmailAddressLabel;
        if (e.Item.ItemType == ListViewItemType.DataItem)
        {
            // Display the email address in italics.
            EmailAddressLabel = (Label)e.Item.FindControl("EmailAddressLabel");
            EmailAddressLabel.Font.Italic = true;

            System.Data.DataRowView rowView = e.Item.DataItem as System.Data.DataRowView;
            string currentEmailAddress = rowView["EmailAddress"].ToString();
            if (currentEmailAddress == "orlando0@adventure-works.com")
            {
                EmailAddressLabel.Font.Bold = true;
            }
        }
    }
    // </Snippet2>
  
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>ListView ItemDataBound Example</title>
</head>
<body style="font: 10pt Trebuchet MS">
    <form id="form1" runat="server">
    <h3>
        ListView ItemDataBound Example</h3>
    <asp:ListView ID="ContactsListView" DataSourceID="ContactsDataSource" ConvertEmptyStringToNull="true"
        OnItemDataBound="ContactsListView_ItemDataBound" runat="server">
        <LayoutTemplate>
            <table cellpadding="2" width="680px" border="0">
                <tr style="background-color: #ADD8E6" runat="server">
                    <th runat="server">
                        First Name
                    </th>
                    <th runat="server">
                        Last Name
                    </th>
                    <th runat="server">
                        Email Address
                    </th>
                </tr>
                <tr runat="server" id="itemPlaceholder" />
            </table>
            <asp:DataPager runat="server" ID="PeopleDataPager" PageSize="12">
                <Fields>
                    <asp:NumericPagerField ButtonCount="10" />
                </Fields>
            </asp:DataPager>
        </LayoutTemplate>
        <ItemTemplate>
            <tr style="background-color: #CAEEFF" runat="server">
                <td>
                    <asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
                </td>
                <td>
                    <asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
                </td>
                <td>
                    <asp:Label ID="EmailAddressLabel" runat="server" Text='<%#Eval("EmailAddress") %>' />
                </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:AdventureWorksConnectionString %>"
        SelectCommand="SELECT FirstName, LastName, EmailAddress FROM SalesLT.Customer">
    </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">

    ' <Snippet2>
    Protected Sub ContactsListView_ItemDataBound(ByVal sender As Object, _
                                                 ByVal e As ListViewItemEventArgs)
  
        If e.Item.ItemType = ListViewItemType.DataItem Then
            ' Display the email address in italics.
            Dim EmailAddressLabel As Label = _
              CType(e.Item.FindControl("EmailAddressLabel"), Label)
            EmailAddressLabel.Font.Italic = True

            Dim rowView As System.Data.DataRowView
            rowView = CType(e.Item.DataItem, System.Data.DataRowView)
            Dim currentEmailAddress As String = rowView("EmailAddress").ToString()
            If currentEmailAddress = "orlando0@adventure-works.com" Then
                EmailAddressLabel.Font.Bold = True
            End If
        End If
        
    End Sub
    ' </Snippet2>

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>ListView ItemDataBound Example</title>
</head>
<body style="font: 10pt Trebuchet MS">
    <form id="form1" runat="server">
    <h3>
        ListView ItemDataBound Example</h3>
    <asp:ListView ID="ContactsListView" DataSourceID="ContactsDataSource" ConvertEmptyStringToNull="true"
        OnItemDataBound="ContactsListView_ItemDataBound" runat="server">
        <layouttemplate>
          <table cellpadding="2" width="680px" border="0">
            <tr style="background-color: #ADD8E6" runat="server">
                <th runat="server">First Name</th>
                <th runat="server">Last Name</th>
                <th runat="server">Email Address</th>
            </tr>
            <tr runat="server" id="itemPlaceholder" />
          </table>
          <asp:DataPager runat="server" ID="PeopleDataPager" PageSize="12">
            <Fields>
              <asp:NumericPagerField ButtonCount="10" /> 
            </Fields>
          </asp:DataPager>
        </layouttemplate>
        <itemtemplate>
          <tr style="background-color: #CAEEFF" runat="server">
            <td>
              <asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
            </td>
            <td>
              <asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
            </td>
            <td>
              <asp:Label ID="EmailAddressLabel" runat="server" Text='<%#Eval("EmailAddress") %>' />
            </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:AdventureWorksConnectionString %>"
        SelectCommand="SELECT FirstName, LastName, EmailAddress FROM SalesLT.Customer">
    </asp:SqlDataSource>
    </form>
</body>
</html>

설명

전에 ListView 컨트롤을 렌더링을 ListViewItem 컨트롤의 각 항목에 대 한 개체를 만들어야 합니다. ItemCreated 때마다 이벤트가 발생 하는 항목에는 ListView 컨트롤이 만들어집니다. 이 항목에 사용자 지정 콘텐츠를 추가 하는 등 항목을 만들 때마다 사용자 지정 루틴을 수행 하는 이벤트 처리 메서드를 제공할 수 있습니다.

마찬가지로, 전에 ListView 컨트롤이 렌더링 될 수, 데이터 원본에서 레코드를 컨트롤에 있는 모든 항목을 바인딩해야 합니다. ItemDataBound 항목이 이벤트는 (나타내는 ListViewItem 개체) 데이터에 바인딩되는 ListView 컨트롤입니다. 이렇게 하면 항목 표시 되기 전에 데이터의 값을 수정 하는 등의 데이터에 바인딩될 때마다 사용자 지정 루틴을 수행할 수 있습니다.

ListViewItemEventArgs 개체 이벤트를 발생 시킨 항목의 속성에 액세스 하는 이벤트 처리 메서드에 전달 됩니다. 만들고 있는 항목 형식 (데이터 항목, 빈 항목 또는 항목 삽입)을 확인 하려면 사용 합니다 ItemType 의 속성을 ListViewItem 개체.

인스턴스의 초기 속성 값의 목록을 ListViewItemEventArgs, 참조는 ListViewItemEventArgs 생성자입니다.

생성자

ListViewItemEventArgs(ListViewItem)

ListViewItemEventArgs 클래스의 새 인스턴스를 초기화합니다.

속성

Item

만들고 있거나 데이터에 바인딩되는 항목을 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보