Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid.DataSource = Array of Objects of Data Container Class...

Status
Not open for further replies.

vinidel

IS-IT--Management
Jan 23, 2004
78
US

My datagrid datasource is an array of objects of data container class.

Me.dGridComments.DataSource = CommentsData.CommentsArray

CommentsData = Object of my worker class
CommentsArray = Array of Objects of my Data Container class.

I want to build a table structure on my datagrid.

Dim dt As DataTable
dt = CType(grid.DataSource, DataTable)

When I run above code, i get this error:

"
An unhandled exception of type 'System.InvalidCastException' occurred in ProjectComments.exe
Additional information: Specified cast is not valid.
"

Any suggestion will be appreciated.

Thanks

NOTE: I cannot change my datasource.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top