views:

13

answers:

2

I want to iterate through HtmlTable (Server Side) in ASP.NET 3.5.

foreach (System.Web.UI.HtmlControls.HtmlTableRow trow in someTable)
{
       var x = trow.InnerText; 
}

I received an error message that "System.Web.UI.HtmlControls.HtmlTable" does not contain a definition for GetEnumerator.

How to write an extension method or alternative to make HtmlTable as enumerable row collection?

Thanks.

+1  A: 

I don't think you want to iterate over the table - presumably you're wanting to iterate over the rows in the table - check this out.

Will A
+1  A: 

Are you going for something more like this?

foreach (HtmlTableRow trow in someTable.Rows)
{
    foreach (HtmlTableCell cell in trow.Cells)
    {
        // ...
    }
}
kbrimington
ohhh i got it thanks
Amit