I'm trying to find a DropDownList in my RadGrid using FindControl() method. But it's always returning null so it cannot find the DropDownList. I have the following HTML code:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"True"
DataSourceID
=
"SqlDataSource1"
GroupPanelPosition
=
"Top"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataSourceID
=
"SqlDataSource1"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"myName"
HeaderText
=
"header text"
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"myDropDown"
DataTextField
=
"TextFieldValue"
DataValueField
=
"ValueFieldValue"
runat
=
"server"
/>
</
EditItemTemplate
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
And I'm trying to find "myDropDown" using this C# code:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
DropDownList list = (DropDownList)item.FindControl(
"myDropDown"
);
}
}
But it cannot find the DropDownList. Can you tell me what I'm doing wrong?
Any help appreciated.
Regards,
Danilo