asp.net.ph

DataTable.Select Method ( String, String, DataViewRowState )

System.Data Namespace   DataTable Class


Returns an array of all DataRow objects that match the filter in the order of the sort, that match the specified state.

[ VB ]
Overloads Public Function Select ( _
   ByVal filterExpression As String, _
   ByVal sort As String, _
   ByVal recordStates As DataViewRowState _
) As DataRow ( )

[ C# ]
public DataRow [ ] Select (
   string filterExpression,
   string sort,
   DataViewRowState recordStates
);

[ C++ ]
public: DataRow* Select (
   String* filterExpression,
   String* sort,
   DataViewRowState recordStates
 ) [ ];

[ JScript ]
public function Select (
   filterExpression : String,
   sort : String,
   recordStates : DataViewRowState
) : DataRow [ ];

Parameters

filterExpression
The criteria to use to filter the rows.
sort
A string specifying the column and sort direction.
recordStates
One of the DataViewRowState values.

Return Value

An array of DataRow objects.

Remarks

To form the filterExpression argument, use the same rules for creating the DataColumn class's Expression property value. The Sort argument also uses the same rules for creating class's Expression strings.

Example

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

private void GetRowsByFilter ( )
   // presuming the DataTable has a column named Date.
   string strExpr = "Date > '1/1/00'";
   // sort descending by column named CompanyName.
   string strSort = "CompanyName DESC";
   // get only new records.
   DataViewRowState recState = DataViewRowState.New;

   DataTable myTable = myDataSet.Tables [ "Orders" ];
   // use the Select method to find all rows matching the filter.
   DataRow foundRows = myTable.Select ( strExpr, strSort, recState );

   // 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   DataRow   DataView   DataViewRowState   Expression Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

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

You can help support asp.net.ph