Metainformationen zur Seite
  •  
Übersetzungen dieser Seite:

Dies ist eine alte Version des Dokuments!


How to filter your row data

This document briefly explains how to use the data filter syntax.

Column names

If a column name contains any of these special characters ~ ( ) # \ / = > < + - * % & | ^ ' „ [ ], you must enclose the column name within square brackets [ ]. If a column name contains right bracket ] or backslash \, escape it with backslash (\] or \\).

  1. "id = 10"; // no special character in column name "id"
  2. "$id = 10"; // no special character in column name "$id"
  3. "[#id] = 10"; // special character "#" in column name "#id"
  4. "[[id\]] = 10"; // special characters in column name "[id]"

Literals

String values are enclosed within single quotes ' '. If the string contains single quote ', the quote must be doubled.

  1. dataView.RowFilter = "Name = 'John'" // string value
  2. dataView.RowFilter = "Name = 'John ''A'''" // string with single quotes "John 'A'"
  3. dataView.RowFilter = String.Format("Name = '{0}'", "John 'A'".Replace("'", "''"));

Number values are not enclosed within any characters. The values should be the same as is the result of int.ToString() or float.ToString() method for invariant or English culture.

  1. dataView.RowFilter = "Year = 2008" // integer value
  2. dataView.RowFilter = "Price = 1199.9" // float value
  3. dataView.RowFilter = String.Format(CultureInfo.InvariantCulture.NumberFormat,
  4. "Price = {0}", 1199.9f);

Date values are enclosed within sharp characters # #. The date format is the same as is the result of DateTime.ToString() method for invariant or English culture.

  1. dataView.RowFilter = "Date = #12/31/2008#" // date value (time is 00:00:00)
  2. dataView.RowFilter = "Date = #2008-12-31#" // also this format is supported
  3. dataView.RowFilter = "Date = #12/31/2008 16:44:58#" // date and time value
  4. dataView.RowFilter = String.Format(CultureInfo.InvariantCulture.DateTimeFormat,
  5. "Date = #{0}#", new DateTime(2008, 12, 31, 16, 44, 58));

Alternatively you can enclose all values within single quotes ' '. It means you can use string values for numbers or date time values. In this case the current culture is used to convert the string to the specific value.

  1. dataView.RowFilter = "Date = '12/31/2008 16:44:58'" // if current culture is English
  2. dataView.RowFilter = "Date = '31.12.2008 16:44:58'" // if current culture is German
  3. dataView.RowFilter = "Price = '1199.90'" // if current culture is English
  4. dataView.RowFilter = "Price = '1199,90'" // if current culture is German
  1.  
  1.  
  1.  
  1.  
  1.