FindControl in GridTemplateColumn in RadGrid

血红的双手。 提交于 2020-01-15 11:42:20

问题


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.

This is what I am trying:

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

Thanks!


回答1:


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");  
}   

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




回答2:


If your UniqueName is not "Account" the code can't find the controls which are in "Account"



来源:https://stackoverflow.com/questions/7936544/findcontrol-in-gridtemplatecolumn-in-radgrid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!