问题
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