C# – FindControl in GridTemplateColumn in RadGrid

cradgridtelerik

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!

Best Answer

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.