473,387 Members | 1,705 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.

Selecting in a DataGrid

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

Sep 4 '08 #1
3 872
On Thu, 4 Sep 2008 14:45:00 -0700, Jackmac
<Ja*****@discussions.microsoft.comwrote:
>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?

Sep 4 '08 #2
Hi Cor,

This is for a WindowsForm DataGrid

"Cor Ligthert[MVP]" wrote:
Hi,

Is this for a ASPNET DataGrid or for a WindowsForm Datagrid?

Cor

"Jackmac" <Ja*****@discussions.microsoft.comschreef in bericht
news:49**********************************@microsof t.com...
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
Sep 5 '08 #3


"Jack Jackson" wrote:
On Thu, 4 Sep 2008 14:45:00 -0700, Jackmac
<Ja*****@discussions.microsoft.comwrote:
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?

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
Sep 5 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: alexB | last post by:
Could it be that the data has changed in such a way as to produce the unexpected results? Or could a newer/older version of the .net framework have been installed on the server? >-----Original...
2
by: Sam74 | last post by:
Hi, I'm writing a program with Microsoft Visual C# .net version 2002 the program has 4 Forms and all the database components (DataSet, OleDbDataAdapter, OleDbConnection) are in form4 as I've got...
2
by: Michael Cairns | last post by:
Im trying to work out how to select a row and change the appearance of the selected row i a datagrid. I might also try to show the details of a selected row on a panel in the page. Is this...
6
by: aaa | last post by:
Hi I am trying to create a read-only DataGrid that would always have current row selected. Currently, I am using method: public void SelectDataGridRow(DataGrid dg) { if (dg.CurrentRowIndex >...
1
by: orekinbck | last post by:
Hi There I have a datagrid whose main purpose in life is to provide a nice way for users to make a single choice from a list. The grid is read only, single row select and has its data source as...
6
by: aaj | last post by:
Hi all I use a data adapter to read numerous tables in to a dataset. The dataset holds tables which in turn holds full details of the records i.e. keys, extra colums etc.. In some cases I...
1
by: Jay | last post by:
Hi All, My users are complaining about the page refreshing when they are selecting multiple rows in a datagrid. Has anyone tried to manage this using javascript? I tried smartnavigation but that...
1
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
0
by: Satiz | last post by:
Hi All, I've a TreeView(IE Webcontrol) and a DataGrid in my VS.Net 2003 ASP.Net web form. My problem : If i select a particular node(it may be parent, child or leaf), then the corresponding...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.