473,387 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Changing database tables displayed in a GridView control

bagrigsb
My project is fairly simple, since I am a relative noobie
to VB.NET. Using a Windows Form with a Menu bar and a
Gridview control, I have bound data to the GridView from
an MS Access 2000 database query using Dataset.
The contents of this table displays just fine.
But I want to be able for the user to select a different
query from the menu bar and display it in the same
GridView control. How can I change the query bound to
the control (in VB)?

Expand|Select|Wrap|Line Numbers
  1. Public Class Actinide
  2.     Private Sub Minerals_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  3.         Me.Actinide_Series__Radioactive_TableAdapter.Fill(Me.Minerals2000DataSet._Actinide_Series__Radioactive_)
  4.     End Sub
  5.     Private Sub LanthanideToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LanthanideToolStripMenuItem.Click
  6.          Me.Actinide_Series__Radioactive_TableAdapter.Fill(Me.Minerals2000DataSet.Lanthanide_Series)
  7.     End Sub
  8.     Private Sub YttriumToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YttriumToolStripMenuItem.Click
  9.         Me.Actinide_Series__Radioactive_TableAdapter.Fill(Me.Minerals2000DataSet.Yttrium_Minerals)
  10.     End Sub
  11. End Class
  12.  
The error message that it is giving me is:
"Value of type 'Mineralogy.Minerals2000DataSet.Yttrium_MineralsDa ta Table cannot be converted to
'Mineralogy.Minerals2000DataSet._Actinide_Series__ Radioactive_Data Table'.

The query is getting information from two seperate tables,
so I can't just bind a table to the control and then
filter what is displayed using SQL. Please Help!
Sep 17 '10 #1
1 1325
TamusJRoyce
110 100+
Don't fill the same table twice. Make two separate DataTables. Then with the DataGridView? set dgv.DataSource = Table1, then when desired set dgv.DataSource = Table2.

I've had times where you also had to do dgv.Refresh(), but I don't think that is necessary here.

Please reply back if I have misinterpreted your question.
Sep 27 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
4
by: GregG | last post by:
Greetings, I have been working with the new GridView control, and while figuring out most of it's idiosyncrasies on my own, have stumbled upon a problem I cannot seem to resolve. We have...
3
by: chelsea | last post by:
I am using a GridView control with a ButtonField and receiving 2 row command events for each click of the button. Is there a configuration switch that I can turn that will ensure I only receive...
0
by: John Smith | last post by:
ASP.Net 2.0 / C# / IIS 6 I have 2 pages. The master page consists of a tabbed menu created using the Menu and MultiView controls. Something like this: ...
1
by: spitapps | last post by:
I have a gridview declaratively added to my webform. This gridview displays data from a stored procedure returned as a dataset. Once the dataset has been modified slightly i bind it to my...
1
by: fireburns | last post by:
Hello, I am using a GridView control which displays data from 2 SQL tables.the columns are project_name,client_name which are from mstproject(its fields are project_id,project_name,client_id,which...
1
by: spitapps | last post by:
In a traditional gridview control the items inserted(bind) into the control are rows and the data is in columns. I have a customer who wants the data fields as rows and the columns as the items...
1
by: TimmyTurner | last post by:
Hi all, I am trying to view an image from the database in the gridview control. I set up my SQLDatasource, and when testing the query i can see the images in the preview table, then i add a...
5
by: DeMuy | last post by:
I have a gridview with AutoGenerateColumns=true that is presenting a challenge to me. Challenge #1 The data structure from the database server follows: Product |Qty...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.