System.Data Namespace DataTable Class
Indicates whether string comparisons within the table are case-sensitive.
Script |
DataTable.CaseSensitive [ = true | false ] |
This property accepts or returns only a boolean value: true if the comparison is case-sensitive; otherwise, false.
The property is read/write with a default value set to the parent DataSet object's CaseSensitive property, or false if the DataTable was created independently of a DataSet.
The CaseSensitive property affects string comparisons in sorting, searching, and filtering.
The following example calls the Select method twice on a DataTable. The first time, the CaseSensitive property is set to true, the second, to false.
Private void CaseSensitiveDemo ( ) {
DataTable tbl = ( DataTable ) myDataGrid.DataSource;
tbl.CaseSensitive = false;
Response.Write ( "CaseSensitive = False" );
// presuming the DataTable has a column named 'id'.
DataRow [ ] foundRows = tbl.Select ( "id = 'abc'" );
// print out DataRow values. Presumes row 0 contains the value we're looking for.
for ( int i = 0; i < foundRows.Length; i++ ) {
Response.Write ( foundRows [ 0 ] [ 0 ] );
}
Response.Write ( "CaseSensitive = True" );
tbl.CaseSensitive = true;
foundRows = tbl.Select ( "id = 'abc'" );
for ( int i = 0; i < foundRows.Length; i++ ) {
Response.Write ( foundRows [ 0 ] [ 0 ] );
}
}
Private Sub CaseSensitiveDemo ( )
Dim tbl As DataTable = CType ( myDataGrid.DataSource, DataTable )
tbl.CaseSensitive = False
Response.Write ( "CaseSensitive = False" )
' presuming the DataTable has a column named 'id'
Dim foundRows ( ) As DataRow = tbl.Select ( "id = 'abc'" )
' print out DataRow values. Presumes row 0 contains the value we're looking for.
Dim i As Integer
For i = 0 To foundRows.GetUpperBound ( 0 )
Response.Write ( foundRows ( 0 ) ( 0 ) )
Next
Response.Write ( "CaseSensitive = True" )
tbl.CaseSensitive = True
foundRows = tbl.Select ( "id = 'abc'" )
For i = 0 To foundRows.GetUpperBound ( 0 )
Response.Write ( foundRows ( 0 ) ( 0 ) )
Next
End Sub |
|
C# |
VB |
DataTable Members Select