This is a migrated thread and some comments may be shown as answers.

Find Control RadFileExplorer in RadGrid

1 Answer 127 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
cmr asked on 07 Jun 2010, 05:46 PM
I am trying to pre-populate the RadFileExplorer's ViewPaths property when an item is selected for editing in the RadGrid control.  In other words, when a user needs to update a record in the grid, the file explorer should default to a specific directory based on certain criteria of the record.  However, when an attempt to locate the file explorer control is made, it cannot be found always resulting in a null assignment.  Is there a particular event to use prior to drawing the EditItemTemplate which contains the file explorer control?  Is there a better way to write the code to perform this dynamic behavior?  Below is some code snippets for the design and C#.

Thanks in advance

Design Page:
<telerik:RadGrid ID="exampleRadGrid" OnItemCommand="exampleRadGrid_ItemCommand"
       <telerik:GridTemplateColumn UniqueName="FileName" DataField="FileName" HeaderText="FileName"  SortExpression="FileName"
              <asp:Label runat="server" Text='<%#Eval("FileName") %>' ID="fileNameLabel" /> 
              <telerik:RadTextBox runat="server" Text='<%# Bind("FileName") %>' ID="fileNameRadTextBox" /> 
              <telerik:RadFileExplorer ID="fileNameRadFileExplorer" runat="server" /> 

C# Code:
protected void exampleRadGrid_ItemCommand(object source, GridCommandEventArgs e) 
   RadFileExplorer fileExplorer1 = (RadFileExplorer)FindControl("fileNameRadFileExplorer"); 
   RadFileExplorer fileExplorer2 = e.Item.FindControl("fileNameRadFileExplorer"as RadFileExplorer;             
   // Both variables result in null. 

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 14 Jun 2010, 09:42 AM
Hi Cmr,

The controls (including RadFileExplorer control) cannot be found inside the exampleRadGrid_ItemCommand event because thy are not created yet. They can be accessed in RadGrid's ItemDataBound event, however.

Best wishes,
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question