.NET Framework Class Library
DataGridViewRowDataBoundItem Property

Gets the data-bound object that populated the row.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
Syntax
<[%$TOPIC/tdhxf08c_en-us_VS_110_1_0_0_0_0%](False)> _
Public ReadOnly Property DataBoundItem As [%$TOPIC/tdhxf08c_en-us_VS_110_1_0_0_0_1%]
[[%$TOPIC/tdhxf08c_en-us_VS_110_1_0_1_0_0%](false)]
public [%$TOPIC/tdhxf08c_en-us_VS_110_1_0_1_0_1%] DataBoundItem { get; }
[[%$TOPIC/tdhxf08c_en-us_VS_110_1_0_2_0_0%](false)]
public:
property [%$TOPIC/tdhxf08c_en-us_VS_110_1_0_2_0_1%]^ DataBoundItem {
	[%$TOPIC/tdhxf08c_en-us_VS_110_1_0_2_0_2%]^ get ();
}
[<[%$TOPIC/tdhxf08c_en-us_VS_110_1_0_3_0_0%](false)>]
member DataBoundItem : [%$TOPIC/tdhxf08c_en-us_VS_110_1_0_3_0_1%] with get

Property Value

Type: SystemObject
The data-bound Object.
Remarks

Accessing data-bound objects directly through row objects is useful when you do not have direct access to the data source containing the objects. It is also convenient when you want to manipulate objects bound to selected rows or to rows passed as arguments to event handlers.

Examples

The following code example demonstrates how to use the DataBoundItem property to access a business object bound to a row. This code example is part of a larger example provided in How to: Access Objects Bound to Windows Forms DataGridView Rows.

Private Sub InvoiceButton_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles InvoiceButton.Click

    For Each row As DataGridViewRow In Me.DataGridView1.SelectedRows

        Dim cust As Customer = TryCast(row.DataBoundItem, Customer)
        If cust IsNot Nothing Then
            cust.SendInvoice()
        End If 

    Next 

End Sub
void invoiceButton_Click(object sender, EventArgs e)
{
    foreach (DataGridViewRow row in this.dataGridView1.SelectedRows)
    {
        Customer cust = row.DataBoundItem as Customer;
        if (cust != null)
        {
            cust.SendInvoice();
        }
    }
}
Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.