I have a datatable of user info. I am trying to perform a search that can be using last name, user's ID or user's role(s). I have a search textbox for name and ID and a search dropdown for user's role. Not all can be blank but any combincation can be used. I am using the following but don;t think it is right since it always returns the entire datatable:
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 partial search on name and ID.