Resolving "Specified cast is not valid" error while seeking a row from DataTable.

added by Rohit
12/22/2013 4:31:58 PM

10 Kicks, 139 Views

In a situation I had to create a Data Table manually and add columns and rows to it. Later I wanted to search for a row in this Data Table using LINQ. As soon as LINQ code was fired I got this error: "Specified cast is not valid". Here I am sharing a sample code to simulate this problem and will tell you how to get rid of this error in this particular situation I mentioned above.