473,396 Members | 2,029 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,396 software developers and data experts.

Getting data from Datagrid

Hi,
How can I get data frrom a datagrid. eg. if I have a datagrid of 2 columns
and 2 rows, how can I get the data from it into array or variables!!!?

Thanks
--
Regads,
Rochdi
Nov 21 '05 #1
4 4211
How you initialized the DataGrid? If by a datatable, get it from your source
datatable, etc.

[]s
Cesar
"Mike" <Mi**@discussions.microsoft.com> escreveu na mensagem
news:0D**********************************@microsof t.com...
Hi,
How can I get data frrom a datagrid. eg. if I have a datagrid of 2 columns
and 2 rows, how can I get the data from it into array or variables!!!?

Thanks
--
Regads,
Rochdi
Nov 21 '05 #2
Mike wrote:
Hi,
How can I get data frrom a datagrid. eg. if I have a datagrid of 2 columns
and 2 rows, how can I get the data from it into array or variables!!!?

Thanks


Dim DT as DataTable = DirectCast(DataGrid.DataSource, DataTable)
For each Row as DataRow in DT
For ii as integer = 0 to DT.Columns.Count - 1
Debug.Writeline(Row(ii).ToString)
Next
Next

If you didn't supply the datagrid with a datatable, cast it to whatever
you did supply it with.
Nov 21 '05 #3
When I tried its comming up with the following error
"Specified cast is not valid." pointing to:
Dim DT as DataTable = DirectCast(DataGrid.DataSource, DataTable)

--
Regads,
Rochdi
"Chris" wrote:
Mike wrote:
Hi,
How can I get data frrom a datagrid. eg. if I have a datagrid of 2 columns
and 2 rows, how can I get the data from it into array or variables!!!?

Thanks


Dim DT as DataTable = DirectCast(DataGrid.DataSource, DataTable)
For each Row as DataRow in DT
For ii as integer = 0 to DT.Columns.Count - 1
Debug.Writeline(Row(ii).ToString)
Next
Next

If you didn't supply the datagrid with a datatable, cast it to whatever
you did supply it with.

Nov 21 '05 #4
Rochdi,

Did you see this sentence in Chris his message

"cast it to whatever you did supply it with".

I hope this helps,

Cor

Nov 21 '05 #5

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

Similar topics

1
by: Robert | last post by:
This is a repost from the other dotnet.csharp forum: I'm including a simple datagrid control on my web form. I have created a Dataview (reportListView) onto a data table to populate it. At its...
1
by: Sławek Mróz | last post by:
Hi! Is it possible to get data just from DataGrid, not binded to any of DataSource? I can't find any suitable properties, every single example is based on binding data:-( I just want to put...
3
by: anand | last post by:
hi, let: dataSet1 is having some data from database. dataView1 = dataSet1.table(0).defaultView dataGrid1.dataSource = dataView1 dataGrid1.TableStyle.add(myTableStyle1)
7
by: Brett Romero | last post by:
I've created a custom datagrid and would like to get only entries displaying in the grid. The datasource may be a table or dataview. So I check for this in the custom datagrid class: if...
9
by: nickyeng | last post by:
Hi My case is i get the error on runtime while getting data from a file. i get this error: Record of 12344 is found! 5 testing 4272 _cygtls::handle_exceptions: Error while dumping...
4
by: nch1978 | last post by:
I am new to programming and am sorry if this post is in the wrong area. I have a listbox bound to a table and a datagrid bound to another one with a connection through xml. I can change the data...
4
by: dfent | last post by:
I'm using MS Access 2003 1 form with 7 sub forms, updating 7 tables. I've split my database but still getting data changes error messages when multiple people are in the database. Any help would be...
6
by: bushwacker | last post by:
Hello all, I'm a chemical engineering student. our teacher has given us a project to do some calculations based on some equations. those equations include constants, which are to be read from a...
5
by: abhi3211 | last post by:
i am using java inside java script page. in that page i want to use two dropdown list. in first dropdown list i am getting data from ms-access database. in second dropdown list i want to get data...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.