DataView RowFilter Syntax [C#]

RowFilter语法

 1         private void btnEnquiry_Click(object sender, EventArgs e)

 2         {

 3             string filterExpression = string.Empty;

 4             //filter QCPass

 5             if (cbbQCPass.SelectedIndex != 0 && cbbQCPass.SelectedIndex != -1)

 6             {

 7                 string qcPassRowFilter = string.Format("qcpass = {0}", cbbQCPass.SelectedItem);

 8                 filterExpression += qcPassRowFilter;

 9             }

10             //filter epc

11             if (!string.IsNullOrWhiteSpace(txtEPC.Text))

12             {

13                 if (!string.IsNullOrEmpty(filterExpression))

14                 {

15                     filterExpression += " AND ";

16                 }

17                 string epcFilter = string.Format("epc like '%{0}%'", txtEPC.Text.Trim());

18                 filterExpression += epcFilter;

19             }

20             //filter seq

21             if (!string.IsNullOrWhiteSpace(txtSEQ.Text))

22             {

23                 if (!string.IsNullOrEmpty(filterExpression))

24                 {

25                     filterExpression += " AND ";

26                 }

27                 string seqFilter = string.Format("seq like '%{0}%'", txtSEQ.Text.Trim());

28                 filterExpression += seqFilter;

29             }

30 

31             if (!string.IsNullOrEmpty(filterExpression))

32             {

33                 _dataSource.DefaultView.RowFilter = filterExpression;

34             }

35             else

36             {

37                 _dataSource.DefaultView.RowFilter = string.Empty;

38             }

39         }
View Code

 

你可能感兴趣的:(filter)