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. 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.
Yes, I have tried that too :(
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.
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
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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.
...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
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.
--
.....
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
| |