multiple tables in a flat grid

  • Thread starter The Burgess Family
  • Start date
T

The Burgess Family

What is the best way to create a datasource for a single flat grid that
pulls from multiple updateable datatables?

I'd like to pull back multiple tables, create relationships between
them, then have a grid bind to a 'view' of these tables so that when I
update a field in the grid, it updates the datatable in which that
field resides.

Thanks,

Chris
 
W

W.G. Ryan eMVP

You can only build a DataView object on one table at a time. What you are
looking for is more of a UI issue than anything else but your best bet is
probably to create a new datatable with the schema that you want the grid to
resemble. Go ahead and fill your original tables like you normally would
and then loop through them adding the respective values to this new table.
Then bind the grid to it. You'd use the reverse to pull the data out.
You'll need to roll your own CRUD logic but fortuntely it's pretty
straightforward to do this (although admittedly it's monotonous). The other
option you have is to create a View at the DB Server (provided you are using
a Database that supports views). Then just do a Select Whatever from
ViewName and it will essentially accomplish what I suggested above. To be
honest, this approach is probably a lot easier in regard to building the
table. In all likelihood you're going to need to roll your own update logic
but at least if you build a view on the db side, you won't have to hit the
db x number of times to fill each table just so that you can turn around and
loop through it again to build the other table. I'd heavily favor the
latter approach - I just mentioned the first so conceptually you'd see where
I was coming from.

Cheers,

Bill
 
T

The Burgess Family

Thanks for the advice, Bill.

I'm building a forecasting system for reps to forecast different
accounts. The products they're forecasting never change, so I was
trying to pull the product information over to the client once, and
then go back and forth to the server for just the updates the rep
enters in.

The product query is using data from another system and takes much
longer to pull (some of the fields are UDFs).

Seemed like a simple problem, but apparently not.

CB
 
W

W.G. Ryan eMVP

I think you can still essentially do what you're looking for. But if you
just wrote a proc to get the data how you wanted it, then pull it all over,
and when the client changes the data you can just send an update/insert via
executenonquery - you should be good to go.

Please note that normally I'd advise JUST the opposite of this approach -
namely that I would use the DataRelations and have different adapters for
the parent/child tables. In this instance though, based on what you are
trying to do, it would save some work doing the heavy lifting server side
since you have 1-1 relationship and you need specialized binding. A lot of
time UI requirements muddy the water.
 
T

The Burgess Family

The catch is that the reps will be forecasting for multiple accounts
and categories in the same session. If the rep switches to a different
account, I do it all over again. I've got it working as you describe,
however, I'm trying to get it working as you would normally advise
(with the separate adapters).

I was thinking of creating a collection of 'SKUForecast' objects that
is built after the tables have been loaded from the server. I'd
populate these objects with data from each of the tables with events
that fire off when units change. When they switch to a different
account or category, I'd go get the forecast records, and reuse the
product datatable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top