I use a DataTable with Information about Users and I want search a user or a list of users in this DataTable. I try it butit don't work :(
Here is my c# code:
public DataTable GetEntriesBySearch(string username,string location,DataTable table)
{
list = null;
list = table;
string expression;
string sortOrder;
expression = "Nachname = 'test'";
sortOrder = "nachname DESC";
DataRow[] rows = list.Select(expression, sortOrder);
list = null; // for testing
list = new DataTable(); // for testing
foreach (DataRow row in rows)
{
list.ImportRow(row);
}
return list;
}
You can use DataView.
DataView dv = new DataView(yourDatatable);
dv.RowFilter = "query"; // query example = "id = 10"