Getting data from Datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Mike said:
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.
 
How you initialized the DataGrid? If by a datatable, get it from your source
datatable, etc.

[]s
Cesar


"Mike" <[email protected]> escreveu na mensagem
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
 
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)
 
Rochdi,

Did you see this sentence in Chris his message

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

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top