本文整理汇总了C#中System.Web.UI.WebControls.DataControlField.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# DataControlField.GetType方法的具体用法?C# DataControlField.GetType怎么用?C# DataControlField.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.DataControlField
的用法示例。
在下文中一共展示了DataControlField.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetProperty
private static void SetProperty(DataControlField target, string propertyName, object value)
{
target.GetType().GetProperty(propertyName).SetValue(target, value, null);
}
示例2: GetButton
private WebControl GetButton(DataControlField fld, string commandName, string commandArg, int itemIdx, int colIdx, string buttonText, string imgUrl)
{
ButtonType btnType = ButtonType.Button;
if (fld is CommandField)
btnType = ((CommandField)fld).ButtonType;
else if (fld is ButtonField)
btnType = ((ButtonField)fld).ButtonType;
else
throw new Exception("Unrecognized DataControlField type: " + fld.GetType().Name);
switch (btnType)
{
case ButtonType.Button:
{
Button btn = new Button();
btn.ID = string.Format("btn{0}_{1}_{2}", commandName, itemIdx, colIdx);
btn.Text = buttonText;
btn.CommandName = commandName;
btn.CommandArgument = commandArg;
return btn;
}
case ButtonType.Link:
{
LinkButton lnk = new LinkButton();
lnk.ID = string.Format("lnk{0}_{1}_{2}", commandName, itemIdx, colIdx);
lnk.Text = buttonText;
lnk.CommandName = commandName;
lnk.CommandArgument = commandArg;
return lnk;
}
case ButtonType.Image:
{
ImageButton img = new ImageButton();
img.ID = string.Format("img{0}_{1}_{2}", commandName, itemIdx, colIdx);
img.ImageUrl = imgUrl;
img.CommandName = commandName;
img.CommandArgument = commandArg;
return img;
}
default:
throw new Exception("Unrecognized control ButtonType: " + btnType.ToString());
}
}