Hi Guys,
Please convert these two blocks of code for me. I need to use a datatable on the highlighted line:
Please convert these two blocks of code for me. I need to use a datatable on the highlighted line:
Code:
List<DataRowView> selectResult = Products.Select(DataSourceSelectArguments.Empty).Cast<DataRowView>().ToList();
for(int i = 0; i < selectResult.Count; i++) {
if(IsSuitableItem(selectResult[i])) {
ASPxDataView1.PageIndex = i / ASPxDataView1.PageCount;
return;
}
}
Code:
bool IsSuitableItem(object dataItem) {
string searchText = searchTextBox.Text.ToLower();
if(dataItem != null && !string.IsNullOrEmpty(searchText)) {
string valueText = DataBinder.Eval(dataItem, "ProductName").ToString().ToLower();
return (valueText.Contains(searchText));
}
return false;
}