我怎樣才能得到ControlCollection中的texboxes?C#ControlCollection擴展GetAllTextboxes
我嘗試:
public static IEnumerable<TextBox> TextBoxes(this ControlCollection controlCollection)
{
return (IEnumerable<TextBox>)controlCollection.Cast<Control>().Where(c => c is TextBox);
}
但我得到了以下錯誤: 無法轉換類型'WhereEnumerableIterator ` 1 System.Web.UI.Control]爲鍵入「對象System.Collections.Generic .IEnumerable ` 1 [System.Web.UI.WebControls.TextBox]'。
我使用Asp.Net 3.5與C#
這實際上是更好的我所需要的! – Melursus 2009-10-11 01:57:33