开发者

Making System.Web.UI.HtmlControls.HtmlTable as Enumerable

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.


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.


Are you going for something more like this?

foreach (HtmlTableRow trow in someTable.Rows)
{
    foreach (HtmlTableCell cell in trow.Cells)
    {
        // ...
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜