开发者

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

开发者 https://www.devze.com 2023-01-10 09:57 出处:网络
I want to iterate through HtmlTable (Server Side) in ASP.NET 3.5. foreach (System.Web.UI.HtmlControls.HtmlTableRow trow in someTable)

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

精彩评论

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