natejacobs
asked on
DataView - RowFilter for unique values
I'm thinking the answer is 'No', but has anyone ever used a DataView's rowfilter property to view unique rows?
Consider a table containing 20 cities and their states ('WI', 'MN', 'IL', etc). Column names are City and State.
If I want to see the indivual states that are represented in the table is there any way to say:
dtState.RowFilter = "Unique State"
Any thoughts on how this might be possible?
Consider a table containing 20 cities and their states ('WI', 'MN', 'IL', etc). Column names are City and State.
If I want to see the indivual states that are represented in the table is there any way to say:
dtState.RowFilter = "Unique State"
Any thoughts on how this might be possible?
amendment
=========
criteria = @"State <> '" + string.Join(@"' AND State <> '",values) + @"'";
=========
criteria = @"State <> '" + string.Join(@"' AND State <> '",values) + @"'";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
b1 -
I thought I would have to do something like this. Thanks for the solution.
It's simpler than what I had in mind.
I thought I would have to do something like this. Thanks for the solution.
It's simpler than what I had in mind.
{
ArrayList states = new ArrayList();
DataRow [] rows = new DataRow [] {table.Rows[0]};
string [] values;
string criteria
while (rows != null && rows.length != 0)
{
states.Add((string)rows[0]
values = (string [])states.ToArray(typeof(s
criteria = @"State <> '" + string.Join(states,@"' AND State <> '") + @"'";
rows = table.Select(criteria);
}
states.Sort();
return states;
}