DataView DV = DataTable.AsDataView();
for(int i=0; i<ConditonQueue.Count; i++)
{
DV.RowFilter = ConditonQueue.ElementAt(i);
}
Here after the loop DV
is filtered only for last element in ConditionQueue
. How can I get DV
with all filter condition on queue applied?
ConditonQueue.ElementAt(i)
returns a string, which is a valid expression for RowFilter
.
Combining all ConditonQueue.ElementAt(i)
will not help in my scenario. I want to apply RowFilter
each time.
As I need to do some calculation after each RowFilter
. AND
ing all conditions will not help.
Is there any other way to recreate the DV
when RowFilter
is applied in loop each time?
Lots of assumption as your question is not clear. Try this
DataView DV = DataTable.AsDataView();
string[] filter = new string[ConditonQueue.Count];
for(int i=0; i<ConditonQueue.Count; i++)
{
filter[i] = ConditonQueue.ElementAt(i).ToString();
}
DV.RowFilter = String.Join(" AND ", filter); // filter1 AND filter2 AND ... AND filterN
I don't like your approach, am sorry to say but I think you have to update the DV so that the new filter is applied to already filtered view
for(int i=0; i<ConditonQueue.Count; i++)
{
DV.RowFilter = ConditonQueue.ElementAt(i);
DV = DV.ToTable().AsDataView();
}