我怎样才能得到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