RadGrid中的gridtemplatecoluml中的FindControl

本文关键字:中的 FindControl gridtemplatecoluml RadGrid | 更新日期: 2023-09-27 18:12:38

有没有人知道如何在gridtemplatecoluml中的RadGrid中的FindControl ?我可以在EditForm中找到它。但它似乎无法在gridtemplatecoluml中找到它。我试图在ItemDataBound事件中做到这一点。if语句永远不会变为真值,也永远不会进入FindControl。

这就是我正在尝试的:

if (e.Item is GridDataItem)
  {
    GridDataItem item = (GridDataItem)e.Item;
    DropDownList ddlAccountLookup = (DropDownList)item["Account"].FindControl("ddlAccountLookup");
  }

谢谢!

RadGrid中的gridtemplatecoluml中的FindControl

Telerik的支持网站显示了完全相同的方法:

if (e.Item is GridDataItem)  
{  
   GridDataItem item = (GridDataItem)e.Item;  
   Label lbl = (Label)item["IsSportingEvent"].FindControl("LabelSporting");  
}   

我建议你在item["Account"]上设置一个断点,并检查其中包含哪些控件。

如果您的UniqueName不是"Account",代码将无法找到"Account"中的控件