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
LVL 1
EXTRHMANAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
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.
0
DhaestCommented:
Currently, .Net2.0 DataGridView control did not provide the build-in row
grouping function, and I do not think there is any easy way to customizing
this function.

Perhaps you can perform a group by in your datatable and rebind it.
HOW TO: Implement a DataSet GROUP BY Helper Class in Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;325685
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EXTRHMANAuthor Commented:
Thanks Dhaest
That was an excellent find and it worked like a charm.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.