GridViewRowEventArgs Sınıf

Tanım

ve RowDataBound olayları için RowCreated veri sağlar.

public ref class GridViewRowEventArgs : EventArgs
public class GridViewRowEventArgs : EventArgs
type GridViewRowEventArgs = class
    inherit EventArgs
Public Class GridViewRowEventArgs
Inherits EventArgs
Devralma
GridViewRowEventArgs

Örnekler

Aşağıdaki örnek, verilere bağlı olan satırın GridViewRowEventArgs özelliklerine erişmek için olay işleme yöntemine geçirilen nesnenin nasıl kullanılacağını gösterir.


<%@ 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 CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
  {
        
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
      // Display the company name in italics.
      e.Row.Cells[1].Text = "<i>" + e.Row.Cells[1].Text + "</i>";
        
    }
    
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>GridView RowDataBound Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView RowDataBound Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        allowpaging="true"
        onrowdatabound="CustomersGridView_RowDataBound" 
        runat="server">
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </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">

  Sub CustomersGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)

    If e.Row.RowType = DataControlRowType.DataRow Then
    
      ' Display the company name in italics.
      e.Row.Cells(1).Text = "<i>" & e.Row.Cells(1).Text & "</i>"
        
    End If
    
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>GridView RowDataBound Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView RowDataBound Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        allowpaging="true"
        onrowdatabound="CustomersGridView_RowDataBound" 
        runat="server">
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
            
    </form>
  </body>
</html>

Açıklamalar

Denetimin işlenebilmesi GridView için önce denetimdeki her satır için bir GridViewRow nesne oluşturulması gerekir. Denetimde RowCreatedGridView her satır oluşturulduğunda olay oluşturulur. Bu, bu olay gerçekleştiğinde bir satıra özel içerik ekleme gibi özel bir yordam gerçekleştiren bir olay işleme yöntemi sağlamanıza olanak tanır.

Benzer şekilde, denetimin işlenebilmesi için önce denetimdeki her satırın GridView veri kaynağındaki bir kayda bağlı olması gerekir. Olay RowDataBound , bir veri satırı (bir GridViewRow nesneyle temsil edilir) denetimdeki GridView verilere bağlı olduğunda oluşturulur. Bu, bu olay gerçekleştiğinde satıra bağlı verilerin değerlerini değiştirme gibi özel bir yordam gerçekleştiren bir olay işleme yöntemi sağlamanıza olanak tanır.

Olayı GridViewRowEventArgs oluşturan satırın özelliklerine erişmenizi sağlayan olay işleme yöntemine bir nesnesi geçirilir. Satırdaki belirli bir hücreye erişmek için özelliğinde bulunan nesnesinin GridViewRowRow özelliğini kullanınCells. Nesnenin özelliğini kullanarak hangi satır türünün (üst bilgi satırı, veri satırı vb.) oluşturulduğunu RowTypeGridViewRow da belirleyebilirsiniz.

Olayları işleme hakkında daha fazla bilgi için bkz. Olayları İşleme ve Oluşturma.

örneğinin ilk özellik değerlerinin GridViewRowEventArgslistesi için oluşturucuya GridViewRowEventArgs bakın.

Oluşturucular

GridViewRowEventArgs(GridViewRow)

GridViewRowEventArgs sınıfının yeni bir örneğini başlatır.

Özellikler

Row

Oluşturulan veya veriye bağlı olan satırı alır.

Yöntemler

Equals(Object)

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

(Devralındığı yer: Object)
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)

Şunlara uygulanır

Ayrıca bkz.