Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello All,

I want to fill my DataTable with the current data displayed in DataGridView/ListBox.
In c# i used to write:
DataTable dt = (DataTable) grdData.DataSource

But here i am using VB.Net and i am very new to it.
I tried to search on google but everywhere i am finding how to assign DataTable to a datagridview.
I even tried this:
Dim dt as DataTable
dt = grdData.DataSource As DataTable

but its not working.

Can anybody tell me how to do this in VB.Net.

Thanks,
Nagendra.
Posted

1 solution

try this

Dim dt As DataTable = DirectCast(grdData.DataSource, DataTable)

iam not sure but you can try.
 
Share this answer
 
Comments
nagendrathecoder 8-Apr-11 2:05am    
Thanks buddy, it worked. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900