Keith,
When you enumerate through the rows, the enumeration returns the row,
not the indexer for the row. Because of that, you can just do this:
foreach (DataRow myRow in yy.Tables[0].Rows)
{
MessageBox.Show((string) myRow["name"]);
}
You don't need to call ToString on the return value of the indexer for
myRow if the type is a string, you can just cast it.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Keith Smith" <ke*********@verizon.net> wrote in message
news:eiLNd.10858$uc.3615@trnddc05...
I know I am missing something simple here. I have tried looking on Google
for a solution, but can't seem to do it. What is wrong with my code...?
foreach (DataRow myRow in yy.Tables[0].Rows)
{
MessageBox.Show((string)yy.Tables[0].Rows[myRow]["name"].ToString());
}
My goal is to MessageBox for each item in the "name" row.