Filtering / Binding Datagridview objects

Hi Experts - I have a windows form that I added some textboxes to from a table (called Master) and VS automatically created the MasterBindingSource, MasterTableAdapter, MasterBindingNavigation etc.... All of this works ok and I can scroll throught the data using the navigation buttons.

Next I want to add a 'subform' as I know it from my MS Access days - I've used a Datagridview and all works ok except it shows all the data in the datagridview not just the data pertaining to the current record on my Master table.

I've attempted filtering the datagridview using code - and it sort of works, but I have it triggering on the navigation buttons and therefore the event triggers before the page updates and therefore the datagrid is always showing the prior records data.

Am I missing a more simple solution and if not when/where should I run the filtering code?

Thanks,

Sam
LVL 1
SamBAsked:
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.

Jorge PaulinoIT Pro/DeveloperCommented:
>> Am I missing a more simple solution and if not when/where should I run the filtering code?

Try on the Datagridview selection change event
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
SamBAuthor Commented:
Hi jpaulino,

Just tried the datagridview selectionchange event - initially it doesn't work because it seems to fire this event before the page is populated with data and therefore my filtering expression has an empty textbox that it doesn't like.

I can get over that by coding a default value to the textbox (although would prefer not to) but even when I do the datagridview only updates to the correct data when I change something in it - not when I move between records on the form.

Thanks,

Sam
0
Jorge PaulinoIT Pro/DeveloperCommented:
Cna you show us your code ?
0
SanclerCommented:
.RowEnter?

On the firing with an empty textbox, how about enclosing the relevant code in a test for the textbox being empty?

Roger
0
SamBAuthor Commented:
Hi Guys, thanks for your advise - I used a bit of both to get it going so spread the points between you.

Cheers,

Sam
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.