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

Find Control RadFileExplorer in RadGrid

1 Answer 120 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
cmr
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"
   <Columns> 
       <telerik:GridTemplateColumn UniqueName="FileName" DataField="FileName" HeaderText="FileName"  SortExpression="FileName"
           <ItemTemplate>                                            
              <asp:Label runat="server" Text='<%#Eval("FileName") %>' ID="fileNameLabel" /> 
           </ItemTemplate> 
           <EditItemTemplate> 
              <telerik:RadTextBox runat="server" Text='<%# Bind("FileName") %>' ID="fileNameRadTextBox" /> 
              <telerik:RadFileExplorer ID="fileNameRadFileExplorer" runat="server" /> 
           </EditItemTemplate> 
       </telerik:GridTemplateColumn> 
   </Columns> 
</telerik:RadGrid> 
 

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
0
Accepted
Fiko
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,
Fiko
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.
Tags
FileExplorer
Asked by
cmr
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Share this question
or