T
Tony Johansson
This method Search below works almost perfect but there is a problem.
This GetCaseList() is returning a DataSet with one DataTable.
In this DataTable we have several column but two are interesting here and
these are
status and enhet
If I look at each row in the DataTable I can see that in some rows status is
blank and in other rows enhet is blank.
Assume that I from the calling program choose "show all" for either status
or enhet.
In this example we can say I choose "show all" for enhet and we can also
assume that we have a couple of rows where we have blank value in enhet
This construction will not include those rows where we had blank values for
enhet
dataView.RowFilter = string.Format("Status LIKE '%{0}%' and DName LIKE
'%{1}%'", status, enhet);
If both status and enhet have values then this construction give me the
correct result
dataView.RowFilter = string.Format("Status LIKE '%{0}%' and DName LIKE
'%{1}%'", status, enhet);
So my question is if there is any fancy way to fix this without write
several statement with RowFilter anf if clauses
public static DataView Search(string status, string enhet)
{
BackEnd backEnd = new BackEnd();
DataView dataView = new DataView(backEnd.GetCaseList().Tables[0]);
if (status == "Show all")
status = "*";
if (enhet == "Show all")
enhet = "*";
if (status == "*" && enhet == "*")
return dataView.
dataView.RowFilter = string.Format("Status LIKE '%{0}%' and DName LIKE
'%{1}%'", status, enhet);
return dataView;
}
//Tony
This GetCaseList() is returning a DataSet with one DataTable.
In this DataTable we have several column but two are interesting here and
these are
status and enhet
If I look at each row in the DataTable I can see that in some rows status is
blank and in other rows enhet is blank.
Assume that I from the calling program choose "show all" for either status
or enhet.
In this example we can say I choose "show all" for enhet and we can also
assume that we have a couple of rows where we have blank value in enhet
This construction will not include those rows where we had blank values for
enhet
dataView.RowFilter = string.Format("Status LIKE '%{0}%' and DName LIKE
'%{1}%'", status, enhet);
If both status and enhet have values then this construction give me the
correct result
dataView.RowFilter = string.Format("Status LIKE '%{0}%' and DName LIKE
'%{1}%'", status, enhet);
So my question is if there is any fancy way to fix this without write
several statement with RowFilter anf if clauses
public static DataView Search(string status, string enhet)
{
BackEnd backEnd = new BackEnd();
DataView dataView = new DataView(backEnd.GetCaseList().Tables[0]);
if (status == "Show all")
status = "*";
if (enhet == "Show all")
enhet = "*";
if (status == "*" && enhet == "*")
return dataView.
dataView.RowFilter = string.Format("Status LIKE '%{0}%' and DName LIKE
'%{1}%'", status, enhet);
return dataView;
}
//Tony