How to access values from DataTable within DataTable


I need to access row of DataTable stored in a row of another DataTable, please guide how I can do that.

Thanks in advance.

Hi @Rohit_More

DirectCast will be useful in this case. Please refer the screenshot blow


  • dt_Main has one row and one column
  • The first row (the only row) contains another data table in first column (only column)
  • First access the data table - dt_Main.Rows(0)(0) 0-row index, 0 - column index
  • Use direct cast to convert it into data table (to avoid the late binding errors)
  • Then use the same indexing method to access any row and column (all data table methods will be applicable)

Refer the xaml for more clarity

DTWithinDT.xaml (7.9 KB)

I’m trying to get data of invoice using document understanding. Below field (items) is at 6th position.

Expression: DirectCast(dts_InvoiceExtraction.Tables(0).Rows(0)(5),DataTable).Rows(0)(0)
dts_InvoiceExtraction - DataSet

But I’m getting error Add Data Row to DataTable: Unable to cast object of type ‘System.String’ to type ‘System.Data.DataTable’.

Got the solution, referred below video


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.