Selecting in a DataGrid

J

Jackmac

Hi all,

Hopefully someone can offer some advice. I've got a form with two data
grids on it. One has names of boxes in it, the other grid has contents of
the boxes. I want to click on a box in grid 'A' and the contents show in
box 'B'. At present it shows the contents of any box I click on. When I go
to another box, it shows the contents for that box. If I go back to any
choice I've made already, it crashes out. Any ideas? The code I'm using is
shown below:

Dim ws_BoxID As String

ws_BoxID = BoxGrid.Rows(BoxGrid.CurrentCell.RowIndex).Cells(0).Value

Dim ws_SQL As String = "SELECT * FROM BoxContent WHERE BoxID = '" & ws_BoxID
& "'"

Debug.Print(ws_SQL)

Dim myDataTable As DataTable

myDataTable = GetDataTableADONET(ws_SQL)

BoxInfoGrid.DataSource = myDataTable

DataGridView1.DataSource = myDataTable
 
J

Jack Jackson

Hi all,

Hopefully someone can offer some advice. I've got a form with two data
grids on it. One has names of boxes in it, the other grid has contents of
the boxes. I want to click on a box in grid 'A' and the contents show in
box 'B'. At present it shows the contents of any box I click on. When I go
to another box, it shows the contents for that box. If I go back to any
choice I've made already, it crashes out. Any ideas? The code I'm using is
shown below:

Dim ws_BoxID As String

ws_BoxID = BoxGrid.Rows(BoxGrid.CurrentCell.RowIndex).Cells(0).Value

Dim ws_SQL As String = "SELECT * FROM BoxContent WHERE BoxID = '" & ws_BoxID
& "'"

Debug.Print(ws_SQL)

Dim myDataTable As DataTable

myDataTable = GetDataTableADONET(ws_SQL)

BoxInfoGrid.DataSource = myDataTable

DataGridView1.DataSource = myDataTable

"crashes out" is hardly descriptive.

What happens?
If there is a runtime error, on which line?
Where is the code you posted (BoxGrid SelectionChanged event?)
What is DataGridView1?
 
J

Jackmac

Jack Jackson said:
"crashes out" is hardly descriptive.

What happens?
If there is a runtime error, on which line?
Where is the code you posted (BoxGrid SelectionChanged event?)
What is DataGridView1?

Hi Jack,

There is no runtime error, it says that I should relax or turn off
constraints in my DataSet. I haven't set any that I'm aware of.
DataGridView1 is one of the DataGrids
 

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