Dim ddlMyUniqueName As GridDropDownColumn = CType(theRadGrid.FindControl("MyUniqueName"), GridDropDownColumn)
gives the error that type Control cannot be converted to GridDropDownColumn.
I have had no problems dynamically setting the DataSourceId for a RadGrid in a Page_Load event. Why can't I do it for the DataSourceId on a GridDropDownColumn so I can use different sources on different pages for the same RadGrid control in a *.ascx control? What is the correct way to do this?
Also where is the best discussion (most clear yet also complete) that explains how to find and manipulate controls dynamically using the FindControl method? Is it consistent for all Telerik controls throughout the hierarchy of controls? Or does it vary depending on context in control lifecycle event?
6 Answers, 1 is accepted
I hope Telerik engineers are watching these threads in the Forums, and I hope that a new version of the Telerik controls will have a better more effective and simple use of a "FindControl" like method. So far in my experience with the Telerik controls, this problem remains the one that I find most unnecessarily awkward and frustrating.
This absolutely should be built in!
Any Telerik admins monitoring this thread? Where do we post requests for features that we can vote on and build support for prioritizing in the next release?
You can submit a feature request with a "Feature Request" form, available from your account. It is similar to a support ticket.
With respect to the issue at hand. The FindControl() method searches for controls nested in another naming container. In this case, the code supplied earlier is the correct one to get a reference to a column, since it has a much different interface. For the masterTableView, you have a FindColumn method, which caters for a similar approach to the one that you requested - you will not have to look through all the columns in the control:
I hope this information helps.
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.