DetailsViewRowCollection Sınıf

Tanım

Denetimdeki DetailsView nesne koleksiyonunu DetailsViewRow temsil eder.

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
Devralma
DetailsViewRowCollection
Uygulamalar

Örnekler

Aşağıdaki kod örneği, bir DetailsView denetimin koleksiyonundaki DetailsViewRow Rows nesneler arasında nasıl yineleme yapılacağını gösterir. Her satırın değeri sayfada görüntülenir.


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

Açıklamalar

DetailsViewRowCollection sınıfı, bir denetimdeki DetailsView nesne koleksiyonunu DetailsViewRow depolamak ve yönetmek için kullanılır. Denetimdeki DetailsView her satır bir DetailsViewRow nesneyle temsil edilir. Denetimi, DetailsView özelliği için sınıfını Rows kullanırDetailsViewRowCollection.

Not

Rows özelliği yalnızca veri satırlarını içerir. Üst bilgi satırına, alt bilgi satırına, üst sayfalandırma satırına ve alt sayfalandırma satırına erişmek için sırasıyla , FooterRow, TopPagerRowve BottomPagerRow özelliklerini kullanınHeaderRow.

sınıfı koleksiyondaki DetailsViewRowCollection öğelere erişmek için çeşitli yolları destekler:

  • Belirli bir DetailsViewRow sıfır tabanlı dizinde Item[] koleksiyondan bir nesneyi doğrudan almak için dizin oluşturucuyu kullanın.

  • GetEnumerator Yöntemini kullanarak koleksiyonda yinelemek için kullanılabilecek bir numaralandırıcı alın.

  • CopyTo Koleksiyondaki öğeleri bir diziye kopyalamak için yöntemini kullanın. Bu, koleksiyondaki öğelere erişmek için kullanılabilir.

Koleksiyondaki öğelerin toplam sayısını belirlemek için özelliğini kullanın Count .

Oluşturucular

DetailsViewRowCollection(ArrayList)

Belirtilen ArrayList nesneyi kullanarak sınıfının yeni bir örneğini DetailsViewRowCollection başlatır.

Özellikler

Count

Nesnedeki DetailsViewRowCollection öğe sayısını alır.

IsReadOnly

Nesnedeki DetailsViewRowCollection satırların değiştirilip değiştirilemeyeceğini belirten bir değer alır.

IsSynchronized

Nesnenin DetailsViewRowCollection eşitlenip eşitlenmediğini belirten bir değer alır (iş parçacığı güvenli).

Item[Int32]

Belirtilen dizindeki DetailsViewRow koleksiyondan nesnesini alır.

SyncRoot

Koleksiyona erişimi eşitlemek için kullanılan nesneyi alır.

Yöntemler

CopyTo(DetailsViewRow[], Int32)

içindeki belirtilen Array dizinden başlayarak bu DetailsViewRowCollection nesnedeki tüm öğeleri belirtilen nesneye Arraykopyalar.

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetEnumerator()

Nesnedeki DetailsViewRowCollection tüm DetailsViewRow nesneleri içeren bir numaralandırıcı döndürür.

GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

ICollection.CopyTo(Array, Int32)

içindeki belirtilen Array dizinden başlayarak bu DetailsViewRowCollection nesnedeki tüm öğeleri belirtilen nesneye Arraykopyalar.

Uzantı Metotları

Cast<TResult>(IEnumerable)

öğesinin IEnumerable öğelerini belirtilen türe atar.

OfType<TResult>(IEnumerable)

Bir öğesinin IEnumerable öğelerini belirtilen türe göre filtreler.

AsParallel(IEnumerable)

Sorgunun paralelleştirilmesini sağlar.

AsQueryable(IEnumerable)

bir IEnumerable öğesini öğesine IQueryabledönüştürür.

Şunlara uygulanır

Ayrıca bkz.