ListViewItemType 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ListView 컨트롤에 있는 항목의 기능을 지정합니다.
public enum class ListViewItemType
public enum ListViewItemType
type ListViewItemType =
Public Enum ListViewItemType
- 상속
필드
DataItem | 0 | ListView 컨트롤의 데이터 항목입니다. |
EmptyItem | 2 | ListView 컨트롤에 있는 빈 항목입니다. ListView 컨트롤에 표시할 레코드가 없거나 ListView 컨트롤의 그룹에 표시할 레코드가 더 이상 없으면 빈 항목이 표시됩니다. |
InsertItem | 1 | ListView 컨트롤에 있는 삽입 항목입니다. |
예제
다음 예제에서는 사용 하는 방법을 보여 줍니다 합니다 ListViewItemType 의 형식을 확인 하는 열거형을 ListViewItem 개체입니다.
<%@ 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>
설명
합니다 ListViewItemType 에 있는 항목의 함수를 식별 하는 열거형을 ListView 컨트롤입니다. 사용할 수는 ListViewItemType 의 형식을 식별 하는 열거형을 ListViewItem 개체입니다.
적용 대상
추가 정보
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET