Link to home
Start Free TrialLog in
Avatar of EXTRHMAN
EXTRHMAN

asked on

creating a dataview with grouping from a datatable

Hi experts,

I have an application that displays product usage information by year in a datagridview.  This typically displays about 150k of records.  I am trying to create an option to group by product (meaning sum up all the years info).  I would like for the user to just select a radio button to change the grouping.  I can run different SQL statments each time but thought there may be a better way, since I have the data already.

Can I create a new view on the table that includes the grouping or is there a way to run an sql statement against the datatable instead of requering the sql server?

Thanks

Mike
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

I guess the simple answer to that is no, you cannot run a query against the datatable and I am not aware of a solution that allows the grid to do the summation dynamically.

One possibility is to return two resultsets from your initial query, one being the unsummed data and the other the summary data. You can then simply switch datatables on the radio button event to avoid having to requery each time this is clicked. It might slightly increase your load time but will avoid the requerying.
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of EXTRHMAN
EXTRHMAN

ASKER

Thanks Dhaest
That was an excellent find and it worked like a charm.