Click here to Skip to main content
16,009,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
ViewData["Contents"] = dataTable.AsEnumerable();
foreach (var m in (IEnumerable<DataTable>) ViewData["LogFileContents"])
          {

          }


But throwing an exception ?
Unable to cast object of type 'System.Data.EnumerableRowCollection`1[System.Data.DataRow]' to type 'System.Collections.Generic.IEnumerable`1[System.Data.DataTable]'.
How can i use this?
Posted
Comments
[no name] 24-Oct-13 6:47am    
try foreach (var m in (IEnumerable<datarow>) ViewData["LogFileContents"])
{

}

Maybe:
C#
foreach (var m in (IEnumerable<DataRow>)ViewData["Contents"])
 
Share this answer
 
v2
XML
ViewData["Contents"] = dataTable.AsEnumerable();
foreach (var m in (IEnumerable<DataTable>) ViewData["Contents"])
          {

          }
 
Share this answer
 

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