NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataRow.Item

[To be supplied.]

[C#] In C#, this member is the indexer for the DataRow class.

Overload List

Gets the data stored at the column, specified by index and version of the data to retrieve.

[Visual Basic] Overloads Public Default ReadOnly Property Item(Integer, DataRowVersion) As Object
[C#] public object this[int, DataRowVersion] {get;}
[C++] public: __property Object* get_Item(int, DataRowVersion);
[JScript] DataRow.Item (int, DataRowVersion)

Gets or sets the data stored at the DataColumn for this row.

[Visual Basic] Overloads Public Default Property Item(DataColumn) As Object
[C#] public object this[DataColumn] {get; set;}
[C++] public: __property Object* get_Item(DataColumn*);
public: __property void set_Item(DataColumn*, Object*);
[JScript] DataRow.Item (DataColumn)

Gets the data stored at the column; the column is specified by passing a DataColumn to the property. Additionally, you can specify which version of the data to retrieve.

[Visual Basic] Overloads Public Default ReadOnly Property Item(DataColumn, DataRowVersion) As Object
[C#] public object this[DataColumn, DataRowVersion] {get;}
[C++] public: __property Object* get_Item(DataColumn*, DataRowVersion);
[JScript] DataRow.Item (DataColumn, DataRowVersion)

Gets the data stored at the column; the column is specified by name. Additionally, you can specify which version of the data to retrieve.

[Visual Basic] Overloads Public Default ReadOnly Property Item(String, DataRowVersion) As Object
[C#] public object this[String, DataRowVersion] {get;}
[C++] public: __property Object* get_Item(String*, DataRowVersion);
[JScript] DataRow.Item (String, DataRowVersion)

Gets or sets the data stored at the specified column index.

[Visual Basic] Overloads Public Default Property Item(Integer) As Object
[C#] public object this[int] {get; set;}
[C++] public: __property Object* get_Item(int);
public: __property void set_Item(int, Object*);
[JScript] DataRow.Item (int)

Gets or sets the data stored at the named column.

[Visual Basic] Overloads Public Default Property Item(String) As Object
[C#] public object this[String] {get; set;}
[C++] public: __property Object* get_Item(String*);
public: __property void set_Item(String*, Object*);
[JScript] DataRow.Item (String)

Example [Visual Basic]

The following examples demonstrate the use of the Item property (DataRow indexer) to get and set the value of a given column index. The first example gets the value of the first column in any row that a user clicks in a System.WinForms.DataGrid control. The second sets a value passed as an argument to the method.

Note   This example shows how to use one of the overloaded versions of the Item property (DataRow indexer). For other examples that may be available, see the individual overload topics.

[Visual Basic]

Private Sub DataGrid1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
   Dim currRow As DataRow
   ' Set the current row using the RowNumber property of the CurrentCell.
   currRow = DataGrid1.DataGridTable.DataTable. _
      Rows(DataGrid1.CurrentCell.RowNumber)
   ' Get the value of the column 1 in the DataTable.
   label1.Text = CurrRow("FirstName")
End Sub
Private Sub SetDataRowValue(ByVal myGrid As DataGrid, ByVal newVal As Object)
   ' Set the value of a column in the last row of a DataGrid.
   Dim t As DataTable
   t = mygrid.DataGridTable.DataTable
   Dim myRow As DataRow
   myRow = t.Rows(t.Rows.Count - 1)
   myRow("FirstName") = newVal
End Sub

See Also

DataRow Class | DataRow Members | System.Data Namespace