473,395 Members | 1,977 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,395 software developers and data experts.

Populating DataGrid


I want to populate the cells of a DataGrid at run time. I don't want to
bind a database to it I simply want to do some calculations and put results
into the grid programmatically. I did this in VB 6.0 using the FlexGrid
control but the I cannot figure out how to specify the row/column of the
cell I want to set in the .Net DataGrid control and how to set its value.

Thanks for your help.


Nov 21 '05 #1
6 1787
The way to do this is by setting up a DataTable at runtime and populating
that, then bind that to the datagrid.

Something like this

Dim DT as DataTable
DT.Columns.Add("NewColumn1")
DT.Columns.Add("NewColumn2")
for ii = 0 to 100
Dim DR as DataRow = DT.NewRow
DR.Item(0) = ii
DR.Item(1) = "Something"
DT.Rows.Add(DR)
next
DataGrid1.Datasource = DT

I didn't write that in the IDE so it might not be perfect, but that's the
idea right there.

Hope it helps
Chris

"fripper" <fr*****@insightbb.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

I want to populate the cells of a DataGrid at run time. I don't want to
bind a database to it I simply want to do some calculations and put
results into the grid programmatically. I did this in VB 6.0 using the
FlexGrid control but the I cannot figure out how to specify the row/column
of the cell I want to set in the .Net DataGrid control and how to set its
value.

Thanks for your help.

Nov 21 '05 #2
The way to do this is by setting up a DataTable at runtime and populating
that, then bind that to the datagrid.

Something like this

Dim DT as DataTable
DT.Columns.Add("NewColumn1")
DT.Columns.Add("NewColumn2")
for ii = 0 to 100
Dim DR as DataRow = DT.NewRow
DR.Item(0) = ii
DR.Item(1) = "Something"
DT.Rows.Add(DR)
next
DataGrid1.Datasource = DT

I didn't write that in the IDE so it might not be perfect, but that's the
idea right there.

Hope it helps
Chris

"fripper" <fr*****@insightbb.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

I want to populate the cells of a DataGrid at run time. I don't want to
bind a database to it I simply want to do some calculations and put
results into the grid programmatically. I did this in VB 6.0 using the
FlexGrid control but the I cannot figure out how to specify the row/column
of the cell I want to set in the .Net DataGrid control and how to set its
value.

Thanks for your help.

Nov 21 '05 #3
Thanks very much Chris ... I am beginning to get a handle on the DataGrid
control. I am sure that buried in the humongous help files that Microsoft
provides is an explanation of this but I sure couldn't find it! Your clear,
concise explanation helps a lot.

"Chris" <chris@No_Spam_Please.com> wrote in message
news:OJ**************@TK2MSFTNGP12.phx.gbl...
The way to do this is by setting up a DataTable at runtime and populating
that, then bind that to the datagrid.

Something like this

Dim DT as DataTable
DT.Columns.Add("NewColumn1")
DT.Columns.Add("NewColumn2")
for ii = 0 to 100
Dim DR as DataRow = DT.NewRow
DR.Item(0) = ii
DR.Item(1) = "Something"
DT.Rows.Add(DR)
next
DataGrid1.Datasource = DT

I didn't write that in the IDE so it might not be perfect, but that's the
idea right there.

Hope it helps
Chris

"fripper" <fr*****@insightbb.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

I want to populate the cells of a DataGrid at run time. I don't want to
bind a database to it I simply want to do some calculations and put
results into the grid programmatically. I did this in VB 6.0 using the
FlexGrid control but the I cannot figure out how to specify the
row/column of the cell I want to set in the .Net DataGrid control and how
to set its value.

Thanks for your help.


Nov 21 '05 #4
Thanks very much Chris ... I am beginning to get a handle on the DataGrid
control. I am sure that buried in the humongous help files that Microsoft
provides is an explanation of this but I sure couldn't find it! Your clear,
concise explanation helps a lot.

"Chris" <chris@No_Spam_Please.com> wrote in message
news:OJ**************@TK2MSFTNGP12.phx.gbl...
The way to do this is by setting up a DataTable at runtime and populating
that, then bind that to the datagrid.

Something like this

Dim DT as DataTable
DT.Columns.Add("NewColumn1")
DT.Columns.Add("NewColumn2")
for ii = 0 to 100
Dim DR as DataRow = DT.NewRow
DR.Item(0) = ii
DR.Item(1) = "Something"
DT.Rows.Add(DR)
next
DataGrid1.Datasource = DT

I didn't write that in the IDE so it might not be perfect, but that's the
idea right there.

Hope it helps
Chris

"fripper" <fr*****@insightbb.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

I want to populate the cells of a DataGrid at run time. I don't want to
bind a database to it I simply want to do some calculations and put
results into the grid programmatically. I did this in VB 6.0 using the
FlexGrid control but the I cannot figure out how to specify the
row/column of the cell I want to set in the .Net DataGrid control and how
to set its value.

Thanks for your help.


Nov 21 '05 #5
You can put your data into a class then the collection of classes into an
arraylist or an array and bind the array or arraylist to the DataGrid.

"fripper" wrote:

I want to populate the cells of a DataGrid at run time. I don't want to
bind a database to it I simply want to do some calculations and put results
into the grid programmatically. I did this in VB 6.0 using the FlexGrid
control but the I cannot figure out how to specify the row/column of the
cell I want to set in the .Net DataGrid control and how to set its value.

Thanks for your help.


Nov 21 '05 #6
You can put your data into a class then the collection of classes into an
arraylist or an array and bind the array or arraylist to the DataGrid.

"fripper" wrote:

I want to populate the cells of a DataGrid at run time. I don't want to
bind a database to it I simply want to do some calculations and put results
into the grid programmatically. I did this in VB 6.0 using the FlexGrid
control but the I cannot figure out how to specify the row/column of the
cell I want to set in the .Net DataGrid control and how to set its value.

Thanks for your help.


Nov 21 '05 #7

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

Similar topics

2
by: Adel | last post by:
Hello guys Does any one know about how to inforce sorting on a specific coloumn in a datagrid before populating it ? Thanks in advance
0
by: Stephen | last post by:
I was wondering if it is possible to take the contents of a row in a datagrid and use an event to copy over the details of the selected row into another datagrid. I'd like to be able to do the...
2
by: Robert | last post by:
I'm sure this is a fairly basic question, but I've been looking all over the web for days for suggestions on how to do this. I've got a datagrid that's bound to a dataset on my form. It includes...
1
by: John | last post by:
Hi all, I have an interesting situation. I have a datagrid I'm currently populating using a dataset but now I need to introduce some extra records into this. I'm unsure of which method to use....
4
by: Paul | last post by:
I sometimes get a timeout error when populating my datagrid, the code is WizardConnection.Open() UpdateCommand.CommandText = "EXECUTE sp_assign_user '" & PhysOffice.SelectedValue & "', '" &...
5
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a...
1
by: Mike P | last post by:
I am populating a drop down column in a datagrid on page load. Here is my code : <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt"...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: Eric B. | last post by:
I am populating a DataGrid with many rows. As it is populating I see the scrollbar flying but no rows pop up until it is finished. Is there a way to make each row draw as soon as it is...
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...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.