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

How to manage a datagrid with 2 dataview as possible datasource?

P: n/a
Hi, I'm using vs2005, .net 2 for windows applciation. I have a form with 1
datagrids whose datasource comes from 2 dataview that are based on 2 dataset
datatables(depends on the stat of the application then one of the dataview
will be selected as datasource for the grid). Both dataview have only 2
columns but one of the columns name is different. Depending on the state of
the application, I would need to change the datasource to be attached to the
datagrid. This is where the problem occurs. The grid has a column created
in the designer that is looking for certain column name in the other dataview
as a datasource. Do I remove and save the column in the grid, add the new
columns name column and reverse it when the application changes? Or, would
it be better if I just create and layer another gird and hide one of the grid
according to the application state? Which would be a better performance
solution? I expect the grid to contain the most is a couple of thousands of
rows.
--
Thanks.
Jun 16 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
columns but one of the columns name is different. Depending on the state
of
the application, I would need to change the datasource to be attached to
the
datagrid. This is where the problem occurs. The grid has a column
created
Keep the data-views in Session, if they're user dependent.
Or else, keep them in Cache. Pick the one needed.
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Jun 16 '07 #2

P: n/a
columns but one of the columns name is different. Depending on the state
of
the application, I would need to change the datasource to be attached to
the
datagrid. This is where the problem occurs. The grid has a column
created
Keep both of them in memory.
When needed, use DataGrid.SetDataBinding(<data-view>, "") to switch from one
view to another.
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------

Jun 16 '07 #3

P: n/a
Keep the data-views in Session, if they're user dependent.
Or else, keep them in Cache. Pick the one needed.
Ignore this posting.
I didn't read that it was a Win-form application. See the other response
that I have already posted.
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Jun 16 '07 #4

P: n/a
Ignore which posting? You think it's better if I don't create an additional
grid to hold the 2nd dataview? I tried switching by setting datasource but
the grid complaint about not able to find the column from the other dataview.
How shoud I address this?
--
Thanks.
"MasterGaurav (www.edujini-labs.com)" wrote:
Keep the data-views in Session, if they're user dependent.
Or else, keep them in Cache. Pick the one needed.

Ignore this posting.
I didn't read that it was a Win-form application. See the other response
that I have already posted.
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Jun 16 '07 #5

P: n/a
Ignore which posting? You think it's better if I don't create an
additional
Ignore the one using "Session/Cache" :-)
grid to hold the 2nd dataview? I tried switching by setting datasource
but
the grid complaint about not able to find the column from the other
dataview.
How shoud I address this?
How are you setting the data source?
You should use the method SetDataBinding in .Net 2.0
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Jun 17 '07 #6

P: n/a
I'm using datagridview and there is no SetDatabinding available. I can
either set datasource or set databinding. Thanks.
--
Thanks.
"MasterGaurav (www.edujini-labs.com)" wrote:
columns but one of the columns name is different. Depending on the state
of
the application, I would need to change the datasource to be attached to
the
datagrid. This is where the problem occurs. The grid has a column
created

Keep both of them in memory.
When needed, use DataGrid.SetDataBinding(<data-view>, "") to switch from one
view to another.
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------

Jun 21 '07 #7

P: n/a
I'm using datagridview and there is no SetDatabinding available. I can
either set datasource or set databinding. Thanks.
Ah! Your earlier posting(s) and even the subject reads "DataGrid". Fix that
:-)

There are two things while setting the DataSource.

1. As soon as the DataSource is set, OnDataSourceChanged method is called
which, apart from other things, refreshes the grid and raises the
DataSourceChanged event
2. If the DataSource instance set is same as the previously set instance,
irrespective of whether the content in the source has changed or not, the
refresh will not happen. If saves precious time and CPU-cycles.

To get across the problem arising out of second scenario, first set the
value of DataSource to null and then to the same input once again.
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Jun 24 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.