2

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!

2 Answers2

6

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.

Icarus
  • 63,293
  • 14
  • 100
  • 115
0

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

nazim hatipoglu
  • 634
  • 10
  • 24