本文介绍了RadGrid 中 GridTemplateColumn 中的 FindControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何在 RadGrid 的 GridTemplateColumn 中查找控件.我可以让它在 EditForm 中找到它.但是好像在GridTemplateColumn中找不到.我试图在 ItemDataBound 事件中执行此操作.if 语句永远不会变为真,也永远不会进入 FindControl.

Does anyone know how to FindControl in the GridTemplateColumn in a RadGrid. I can get it to find it find in EditForm. But it can't seem to find it in the GridTemplateColumn. I am trying to do this in the ItemDataBound event. The if statement never becomes true and never gets into to FindControl.

这就是我正在尝试的:

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

谢谢!

推荐答案

Telerik 的支持网站 显示的方式与您完全相同:

Telerik's support website shows exactly the same way you are doing it:

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

我建议您在 item["Account"] 上设置一个断点,并观察其中包含哪些控件.

I suggest that you put a break point on item["Account"] and do a watch to inspect what controls are contained inside it.

这篇关于RadGrid 中 GridTemplateColumn 中的 FindControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 00:19