首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

会输出控件类型吗

2012-09-14 
能输出控件类型吗?比如要好多FindControl有DropDownList的控件,有TextBox的控件,大部分获得控件再读控件上

能输出控件类型吗?
比如要好多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 

热点排行