I have user information. I am trying to perform a search that can use a name, user id, or user role. I have a search text box for the name and identifier and a drop-down list for the search for the user role. Not everyone can be empty, but any combination can be used. I use the following, but I don’t think it’s correct, since it always returns the whole data type:
dtUsers.CaseSensitive = false;
var results = dtUsers.AsEnumerable()
.Where(r => r.Field<String>("LASTNAME").Contains(tbName.Text.Trim())
|| r.Field<String>("USERID").Contains(tbUserID.Text.Trim())
|| r.Field<String>("USERROLELIST").Contains(ddlRoles.SelectedItem.Text));
dtUsers = results.CopyToDataTable();
What am I doing wrong? I also need to be able to do a partial search by name and id.
source
share