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

DataGrid/DataTable

I am in pain here, so help please. I have a form with a
datagrid control to display a single datatable (created in
memory). I use the form's new sub to initialize the
datatable and set the schema and set the datagrid source,
so when the form is displayed you could see the table (no
datarows) it shows null in the first row. Now my problem
is once I collect the information I need to put in the
table. I use a procedure where I create a reference to
the datatable and add the datarows and finally reasign the
datasource of the datagrid using SetDataBinding() method,
but nothing is displyied. I am not using a dataset. I am
not sure if this is the way of doing this, so any
suggestions will be really appreciated.
Jul 21 '05 #1
5 1427
Not sure if I have all your info but have you done a .Refresh on the datagrid
after assignment?
Tom Y.

"JLong" wrote:
I am in pain here, so help please. I have a form with a
datagrid control to display a single datatable (created in
memory). I use the form's new sub to initialize the
datatable and set the schema and set the datagrid source,
so when the form is displayed you could see the table (no
datarows) it shows null in the first row. Now my problem
is once I collect the information I need to put in the
table. I use a procedure where I create a reference to
the datatable and add the datarows and finally reasign the
datasource of the datagrid using SetDataBinding() method,
but nothing is displyied. I am not using a dataset. I am
not sure if this is the way of doing this, so any
suggestions will be really appreciated.

Jul 21 '05 #2
Yes, I have tried that too :(
Jul 21 '05 #3
You shouldn't need to reassign the DataSource of the DataGrid. Can you
give us some code to further help you out? Are you sure the DataTable gets
the new rows?

Chris

"JLong" <an*******@discussions.microsoft.com> wrote in message
news:0f****************************@phx.gbl...
I am in pain here, so help please. I have a form with a
datagrid control to display a single datatable (created in
memory). I use the form's new sub to initialize the
datatable and set the schema and set the datagrid source,
so when the form is displayed you could see the table (no
datarows) it shows null in the first row. Now my problem
is once I collect the information I need to put in the
table. I use a procedure where I create a reference to
the datatable and add the datarows and finally reasign the
datasource of the datagrid using SetDataBinding() method,
but nothing is displyied. I am not using a dataset. I am
not sure if this is the way of doing this, so any
suggestions will be really appreciated.

Jul 21 '05 #4
Here is the function I am using.

Public Function AddData()
Dim cDataTable As DataTable
Dim Dcolumn As DataColumn
Dim cgrid As DataGrid
Dim myRow As DataRow
Dim I As Int16

cgrid = Me.grdInfo

cDataTable = cgrid.DataSource

For I = 0 To 5
myRow = cDataTable.NewRow()
myRow(0) = "Yes"
myRow(1) = "it"
myRow(2) = "should"
myRow(3) = "work"
cDataTable.Rows.Add(myRow)
Next I

cgrid.DataSource = cDataTable

End Function

Just note, the grid is displayed on the form and contains
the column structure as per the datatable. Here I am
trying to add data to the table. I have tryied printing
to the console the column colection and the rows and it
seems to be fine. However, I can't update the grid to
display the new added data. TIA
Jul 21 '05 #5
Well I think I just found what the problem is. See, the
datagrid is on a form which is a child of the a main
form. I use a dialogbox (a form) to alow the user to
select the file from which the data is to be collected.
The dialogbox is displayed by way of a manu on the main
form. Once the user select the files and click OK then
the function to collect and add the data to the table is
executed. That function is on the child form, the one with
the grid. When OK is clicked, I hide the dialogbox and
call the function. This seems to be the problem, because
if I execute the function by clicking on the child form,
it works fine. So, now I need to find a where to put the
function, how to execute it, and how to hide/close the
dialogbox.
Jul 21 '05 #6

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

Similar topics

0
by: Emerson | last post by:
The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C# Here's my scenario I click in a cell on a DataGrid. I enter some...
3
by: Newbie | last post by:
I am using a Datagrid to show the contents of a DataTable. But it seems like the Datagrid is not getting the contents of the Datatable when the button ( btnAddAnotherLaborCategory) is clicked. ...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
4
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
8
by: Strahimir Antoljak | last post by:
I bound a DataGrid to a table (I tried with a DataView too). I removed the row from the table, and then inserted a new row at the same row index. the table gets the row to the right position, but...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.