How to extract last row value from datatable

I have extracted a few page numbers that are displayed as buttons from a webpage and saved it to datatable using data scraping. I need to get the last page number from the datatable. That is the last row, which has the page number. Please let me know, how to do it.

welcome to the forum

following statements will do it:
Within an assign activity:
leftside: LastRow (DataType is DataRow)
right side:

  • YourDatatableVar.AsEnumeration.Last()
  • YourDatatableVar.Rows(YourDatatableVar.Rows.Count-1)

Hi, Both the above options are not working as expected.
For the first one - I am facing a compiler error. For the second, when I try to view the output using writeline - I simply get system.out.datatable as output, not the value. Please let me know if there is any other solution to this.

it is always better to share validation messages with us, so we can more close react. Maybe it is telling that AsEnumerable is not available then fix with following:
AsEnumerable is not a member of 'System.Data.Datatable'

See the prototyped statements and it outputs from the watch panel. You can see that it is working:


find starter help here:
GetLastRow.xaml (7.1 KB)

Just for demo purpose, find an example on retrieving a column value from the last row:

1 Like

here we do debugging / setting Breakpoints instead and analyse it within the locals / watch / immediate panel
Good introduction on this is the Debugging Course in the Academy

thanks for the example xaml. But inspite of adding the line ‚ÄúSystem.Data.DataSetExtensions</AssemblyReference‚ÄĚ, in my xaml, the issue - AsEnumerable is not a member of 'System.Data.Datatable, doesnot seem to vanish



As mentioned above, the alternativ Statement can be used:

  • YourDatatableVar.Rows(YourDatatableVar.Rows.Count-1)