By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,395 Members | 2,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,395 IT Pros & Developers. It's quick & easy.

Multiple datagridviews same form

P: n/a
I am using VB within VS 2005. How can I have multiple datagridviews on the
same form pulling from the same table? e.g. I want to see all clients from
New York in one view and all clients from LA in another view on the same
form. I've set up a parameterized tableadapter and pass it the city. How can
I load the two views in VB code when the form loads?

Thanks,

Tom
Sep 29 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Hi Tom,

Pull all of your data into a dataset and then just create two dataviews from
your dataset. Then assign each dataview to a separate grid.

ex:

.....code to load dataset

Dim dv1 As DataView = New DataView(ds.Table ("MyTableName"), "city=NY", "",
DataViewRowState.CurrentRows)

Dim dv2 As DataView = New DataView(ds.Table ("MyTableName"), "city=LA", "",
DataViewRowState.CurrentRows)

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"TomH" wrote:
I am using VB within VS 2005. How can I have multiple datagridviews on the
same form pulling from the same table? e.g. I want to see all clients from
New York in one view and all clients from LA in another view on the same
form. I've set up a parameterized tableadapter and pass it the city. How can
I load the two views in VB code when the form loads?

Thanks,

Tom
Sep 29 '06 #2

P: n/a

....or (thinking more in terms of performance) just call your table adapter
query twice - once for LA and once for NY - assigning the results to a
different dataset (i.e. create two datasets in your client application). Then
assign each dataset to a different grid.

You can essentially have as many datasets as you want in your app:

ex:

Dim ds as new system.data.dataset
Dim ds2 as new system.data.dataset
Dim ds3 as new system.data.dataset

....and just fill each one of them up with different calls to your table
adapter.

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"Franklin M. Gauer III" wrote:
>
Hi Tom,

Pull all of your data into a dataset and then just create two dataviews from
your dataset. Then assign each dataview to a separate grid.

ex:

....code to load dataset

Dim dv1 As DataView = New DataView(ds.Table ("MyTableName"), "city=NY", "",
DataViewRowState.CurrentRows)

Dim dv2 As DataView = New DataView(ds.Table ("MyTableName"), "city=LA", "",
DataViewRowState.CurrentRows)

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"TomH" wrote:
I am using VB within VS 2005. How can I have multiple datagridviews on the
same form pulling from the same table? e.g. I want to see all clients from
New York in one view and all clients from LA in another view on the same
form. I've set up a parameterized tableadapter and pass it the city. How can
I load the two views in VB code when the form loads?

Thanks,

Tom
Sep 29 '06 #3

P: n/a
Thanks for the responses. Creating multiple datasets works. However, I would
prefer to create my datasets and dataviews on the form at design time, rather
than create them on the fly at runtime. It also appears multiple datasets
will require me to create duplicate queries (in seperate tableadapters),
resulting in more difficult maintenance if the query changes.

Thanks again,

Tom

"Franklin M. Gauer III" wrote:
>
...or (thinking more in terms of performance) just call your table adapter
query twice - once for LA and once for NY - assigning the results to a
different dataset (i.e. create two datasets in your client application). Then
assign each dataset to a different grid.

You can essentially have as many datasets as you want in your app:

ex:

Dim ds as new system.data.dataset
Dim ds2 as new system.data.dataset
Dim ds3 as new system.data.dataset

...and just fill each one of them up with different calls to your table
adapter.

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"Franklin M. Gauer III" wrote:

Hi Tom,

Pull all of your data into a dataset and then just create two dataviews from
your dataset. Then assign each dataview to a separate grid.

ex:

....code to load dataset

Dim dv1 As DataView = New DataView(ds.Table ("MyTableName"), "city=NY", "",
DataViewRowState.CurrentRows)

Dim dv2 As DataView = New DataView(ds.Table ("MyTableName"), "city=LA", "",
DataViewRowState.CurrentRows)

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"TomH" wrote:
I am using VB within VS 2005. How can I have multiple datagridviews on the
same form pulling from the same table? e.g. I want to see all clients from
New York in one view and all clients from LA in another view on the same
form. I've set up a parameterized tableadapter and pass it the city. How can
I load the two views in VB code when the form loads?
>
Thanks,
>
Tom
Oct 2 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.