ListView.GroupItemCount 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ListView 컨트롤에서 그룹 당 표시할 항목의 수를 가져오거나 설정합니다.
public:
virtual property int GroupItemCount { int get(); void set(int value); };
public virtual int GroupItemCount { get; set; }
member this.GroupItemCount : int with get, set
Public Overridable Property GroupItemCount As Integer
속성 값
ListView 컨트롤에서 그룹 당 표시할 항목의 수입니다. 기본값은 1로, 이는 ListView 컨트롤에서 그룹 당 하나의 항목을 표시함을 나타냅니다.
예외
GroupItemCount 속성이 1보다 작은 값으로 설정된 경우
예제
다음 예제에서는 속성을 사용 하 여 컨트롤에서 바일형 레이아웃을 ListView 만드는 방법을 보여 있습니다 GroupItemCount . 또한 프로그래밍 방식으로이 속성을 변경 하는 방법을 보여 줍니다.
<%@ 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">
protected void GroupItemCountList_SelectedIndexChanged(object sender, EventArgs e)
{
// Changes the number of items displayed for each group.
ContactsListView.GroupItemCount =
Convert.ToInt32(GroupItemCountList.SelectedValue);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ListView GroupItemCount Example</title>
<style type="text/css">
body { font: 10pt Trebuchet MS; }
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView GroupItemCount Example</h3>
Number of columns:
<asp:DropDownList ID="GroupItemCountList"
AutoPostBack="true"
runat="server"
OnSelectedIndexChanged="GroupItemCountList_SelectedIndexChanged"
>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem Selected="True">2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<hr />
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
GroupItemCount="2"
runat="server">
<LayoutTemplate>
<table id="tblContacts" runat="server" cellspacing="0" cellpadding="2">
<tr runat="server" id="groupPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ContactsDataPager" PageSize="24">
<Fields>
<asp:NextPreviousPagerField
ShowFirstPageButton="true" ShowLastPageButton="true"
FirstPageText="|<< " LastPageText=" >>|"
NextPageText=" > " PreviousPageText=" < " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<td align="center" style="width:10px" runat="server">
<asp:Label ID="IDLabel" runat="Server" Text='<%#Eval("ContactID") %>' />
</td>
<td style="width:70px" runat="server">
<asp:Label ID="FirstNameLabel" runat="Server" Text='<%#Eval("FirstName") %>' />
</td>
<td style="width:70px" runat="server">
<asp:Label ID="LastNameLabel" runat="Server" Text='<%#Eval("LastName") %>' />
</td>
</ItemTemplate>
<GroupTemplate>
<tr runat="server" id="ContactsRow" style="background-color: #FFFFFF">
<td runat="server" id="itemPlaceholder" />
</tr>
</GroupTemplate>
<ItemSeparatorTemplate>
<td runat="server" style="border-right: 1px solid #00C0C0"> </td>
</ItemSeparatorTemplate>
</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] FROM Person.Contact">
</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">
Protected Sub GroupItemCountList_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As EventArgs)
' Changes the number of items displayed for each group.
ContactsListView.GroupItemCount = _
Convert.ToInt32(GroupItemCountList.SelectedValue)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ListView GroupItemCount Example</title>
<style type="text/css">
body { font: 10pt Trebuchet MS; }
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView GroupItemCount Example</h3>
Number of columns:
<asp:DropDownList ID="GroupItemCountList"
AutoPostBack="true"
runat="server"
OnSelectedIndexChanged="GroupItemCountList_SelectedIndexChanged"
>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem Selected="True">2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<hr />
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
GroupItemCount="2"
runat="server">
<LayoutTemplate>
<table id="tblContacts" runat="server" cellspacing="0" cellpadding="2">
<tr runat="server" id="groupPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ContactsDataPager" PageSize="24">
<Fields>
<asp:NextPreviousPagerField
ShowFirstPageButton="true" ShowLastPageButton="true"
FirstPageText="|<< " LastPageText=" >>|"
NextPageText=" > " PreviousPageText=" < " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<td align="center" style="width:10px" runat="server">
<asp:Label ID="IDLabel" runat="Server" Text='<%#Eval("ContactID") %>' />
</td>
<td style="width:70px" runat="server">
<asp:Label ID="FirstNameLabel" runat="Server" Text='<%#Eval("FirstName") %>' />
</td>
<td style="width:70px" runat="server">
<asp:Label ID="LastNameLabel" runat="Server" Text='<%#Eval("LastName") %>' />
</td>
</ItemTemplate>
<GroupTemplate>
<tr runat="server" id="ContactsRow" style="background-color: #FFFFFF">
<td runat="server" id="itemPlaceholder" />
</tr>
</GroupTemplate>
<ItemSeparatorTemplate>
<td runat="server" style="border-right: 1px solid #00C0C0"> </td>
</ItemSeparatorTemplate>
</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] FROM Person.Contact">
</asp:SqlDataSource>
</form>
</body>
</html>
설명
컨트롤에서 GroupItemCount 함께 ListView 그룹화할 항목 수를 지정하려면 이 속성을 사용합니다. 즉, 컨트롤의 각 그룹에 대해 표시할 항목 수를 지정합니다. 각 그룹에 대해 컨트롤은 ListView 템플릿의 GroupTemplate 콘텐츠를 렌더링하고 항목 자리 표시자를 실제 항목 콘텐츠로 바꿉니다. 이 작업은 속성에 정의된 항목 수의 횟수만큼 이 작업을 수행합니다 GroupItemCount .
템플릿을 사용하여 GroupItemCount 컨트롤에 GroupTemplate 바일형 레이아웃을 ListView 만들 수 있습니다. 타일식 표 레이아웃에서는 항목이 행에서 가로로 반복됩니다. 항목이 반복되는 횟수는 속성에 GroupItemCount 의해 지정됩니다.