能输出控件类型吗?
比如要好多FindControl
有DropDownList的控件,有TextBox的控件,大部分获得控件再读控件上的text的代码是一样的,只有
string strTemp = (row.FindControl("ddl" + ColumnNames[i]) as DropDownList).Text.Trim();
string strTemp = (row.FindControl("tb" + ColumnNames[i]) as TextBox).Text.Trim();
有没有办法,把这里的 as 后面到底是哪种控件类型,写成一个代码
string strTemp = (row.FindControl(ctrlname) as (ctrlname.Find("ddl")? DropDownList:TextBox).Text.Trim();
------解决方案--------------------
C# code
string strTemp = (row.FindControl("ddl" + ColumnNames[i]) as ITextControl).Text