DetailsViewRowCollection 클래스

정의

DetailsViewRow 컨트롤에 있는 DetailsView 개체의 컬렉션을 나타냅니다.

public ref class DetailsViewRowCollection : System::Collections::ICollection
public class DetailsViewRowCollection : System.Collections.ICollection
type DetailsViewRowCollection = class
    interface ICollection
    interface IEnumerable
Public Class DetailsViewRowCollection
Implements ICollection
상속
DetailsViewRowCollection
구현

예제

다음 코드 예제에는 반복 하는 방법을 보여 줍니다.는 DetailsViewRow 개체를 Rows 의 컬렉션을 DetailsView 제어 합니다. 그러면 각 행의 값은 페이지에 표시 됩니다.


<%@ 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 SubmitButton_Click(Object sender, EventArgs e)
  {

    // Use the Count property to determine whether the
    // Rows collection contains any item.
    if (ItemDetailsView.Rows.Count > 0)
    {
      // Iterate through the Rows collection and display
      // the value of each field.
      MessageLabel.Text = "The row values are: <br/><br/>";

      foreach (DetailsViewRow row in ItemDetailsView.Rows)
      {
        // Use the Text property to access the value of 
        // each cell. In this example, the cells in the 
        // first column (index 0) contains the field names, 
        // while the cells in the second column (index 1)
        // contains the field value. 
        MessageLabel.Text += row.Cells[0].Text + " = " +
          row.Cells[1].Text + "<br/>";
      }
    }
    else
    {
      MessageLabel.Text = "No items.";
    }

  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsViewRowCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>DetailsViewRowCollection Example</h3>
  
      <asp:detailsview id="ItemDetailsView"
        datasourceid="DetailsViewSource"
        allowpaging="true"
        autogeneraterows="false" 
        runat="server">
        <fields>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID"/>
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </fields>
      </asp:detailsview>
      
      <br/>
      
      <asp:button id="SubmitButton" 
        text="Display Row Values"
        onclick="SubmitButton_Click"
        runat="server"/>
        
      <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]"
        connectionstring=
          "<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>  
  
    </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 SubmitButton_Click(ByVal sender As Object, ByVal e As EventArgs)
 
    ' Use the Count property to determine whether the
    ' Rows collection contains any item.
    If ItemDetailsView.Rows.Count > 0 Then
    
      ' Iterate through the Rows collection and display
      ' the value of each field.
      MessageLabel.Text = "The row values are: <br/><br/>"
    
      Dim row As DetailsViewRow
    
      For Each row In ItemDetailsView.Rows
    
        ' Use the Text property to access the value of 
        ' each cell. In this example, the cells in the 
        ' first column (index 0) contains the field names, 
        ' while the cells in the second column (index 1)
        ' contains the field value. 
        MessageLabel.Text &= row.Cells(0).Text & " = " & _
          row.Cells(1).Text & "<br/>"
    
      Next
    
    Else
      
      MessageLabel.Text = "No items."
    
    End If
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsViewRowCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>DetailsViewRowCollection Example</h3>
  
      <asp:detailsview id="ItemDetailsView"
        datasourceid="DetailsViewSource"
        allowpaging="true"
        autogeneraterows="false" 
        runat="server">
        <fields>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID"/>
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </fields>
      </asp:detailsview>
      
      <br/>
      
      <asp:button id="SubmitButton" 
        text="Display Row Values"
        onclick="SubmitButton_Click"
        runat="server"/>
        
      <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]"
        connectionstring=
          "<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>  
  
    </form>
  </body>
</html>

설명

DetailsViewRowCollection 클래스를 저장 및 컬렉션을 관리 하는 데 사용 됩니다 DetailsViewRow 개체를 DetailsView 제어 합니다. 각 행을 DetailsView 컨트롤은 표현는 DetailsViewRow 개체입니다. 합니다 DetailsView 컨트롤이 사용 하는 DetailsViewRowCollection 클래스에 대 한 해당 Rows 속성입니다.

참고

Rows 속성에는 데이터 행만 포함 되어 있습니다. 행 머리글, 바닥글 행, 위쪽 페이저 행 및 아래쪽 페이저 행에 액세스 하려면 사용 합니다 HeaderRow, FooterRowTopPagerRow, 및 BottomPagerRow 속성을 각각.

DetailsViewRowCollection 클래스는 컬렉션의 항목에 액세스 하는 여러 방법을 지원 합니다.

  • 사용 하 여는 Item[] 인덱서를 직접 검색 하는 DetailsViewRow 특정 인덱스에서 컬렉션의 개체입니다.

  • 사용 된 GetEnumerator 메서드 컬렉션을 반복 하는 데 사용할 수 있는 열거자를 검색 합니다.

  • 사용 된 CopyTo 컬렉션의 항목에 액세스를 사용할 수 있는 배열 컬렉션의 항목을 복사 하는 방법입니다.

컬렉션에서 항목의 총 수를 확인 하려면 사용 된 Count 속성입니다.

생성자

DetailsViewRowCollection(ArrayList)

지정된 ArrayList 개체를 사용하여 DetailsViewRowCollection 클래스의 새 인스턴스를 초기화합니다.

속성

Count

DetailsViewRowCollection 개체의 항목 수를 가져옵니다.

IsReadOnly

DetailsViewRowCollection 개체의 행을 수정할 수 있는지 여부를 나타내는 값을 가져옵니다.

IsSynchronized

DetailsViewRowCollection 개체가 동기화되어 스레드로부터 안전한지 여부를 나타내는 값을 가져옵니다.

Item[Int32]

컬렉션의 지정한 인덱스에서 DetailsViewRow 개체를 가져옵니다.

SyncRoot

컬렉션에 대한 액세스 권한을 동기화하는 데 사용된 개체를 가져옵니다.

메서드

CopyTo(DetailsViewRow[], Int32)

Array의 지정된 인덱스에서 시작하여 이 DetailsViewRowCollection 개체의 모든 항목을 지정된 Array 개체로 복사합니다.

Equals(Object)

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

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

DetailsViewRow 개체의 모든 DetailsViewRowCollection 개체를 포함하는 열거자를 반환합니다.

GetHashCode()

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

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

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

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

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

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

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

(다음에서 상속됨 Object)

명시적 인터페이스 구현

ICollection.CopyTo(Array, Int32)

Array의 지정된 인덱스에서 시작하여 이 DetailsViewRowCollection 개체의 모든 항목을 지정된 Array 개체로 복사합니다.

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보