asp.net.ph

DataTable.Select Method ( String )

System.Data Namespace   DataTable Class


Returns an array of all DataRow objects that match the filter criteria in order of primary key ( or lacking one, order of addition. )

[ VB ]
Overloads Public Function Select ( _
   ByVal filterExpression As String _
) As DataRow ( )

[ C# ]
public DataRow [ ] Select (
   string filterExpression
);

[ C++ ]
public: DataRow* Select (
   String* filterExpression
 ) [ ];

[ JScript ]
public function Select (
   filterExpression : String
) : DataRow [ ];

Parameters

filterExpression
The criteria to use to filter the rows.

Return Value

An array of DataRow objects.

Remarks

To create the filterExpression argument, use the same rules that apply to the DataColumn class's Expression property value for creating filters.

Example

The following example uses a filter expression to return an array of DataRow objects.

private void GetRowsByFilter ( )
   // presuming the DataTable has a column named Date.
   string strExpr = "Date > '1/1/00'";
   DataTable myTable = myDataSet.Tables [ "Orders" ];
   // use the Select method to find all rows matching the filter.
   DataRow [ ] foundRows = myTable.Select ( strExpr );

   // print column 0 of each returned row.
   for ( i = 0; i < foundRows.Length; i ++ ) {
      Response.Write ( foundRows [ ] [ 0 ] );
   }
}
  C# VB

See Also

DataTable Members   DataTable.Select Overload List   CaseSensitive   Expression   DataRow Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note