How to filter data in dataview

前端 未结 2 1580
闹比i
闹比i 2021-01-04 14:04

I want to filter data on the textchange event on listview so I use dataview to filter data. Issue in the below code is, I use dataview inside for each so that it checks onl

2条回答
  •  耶瑟儿~
    2021-01-04 14:38

    Eg:

    Datatable newTable =  new DataTable();
    
                foreach(string s1 in list)
                {
                    if (s1 != string.Empty) {
                        dvProducts.RowFilter = "(CODE like '" + serachText + "*') AND (CODE <> '" + s1 + "')";
                        foreach(DataRow dr in dvProducts.ToTable().Rows)
                        {
                           newTable.ImportRow(dr);
                        }
                    }
                }
    ListView1.DataSource = newTable;
    ListView1.DataBind();
    

提交回复
热议问题