Find Control RadFileExplorer in RadGrid

2 posts, 1 answers
  1. cmr
    cmr avatar
    7 posts
    Member since:
    Jun 2010

    Posted 07 Jun 2010 Link to this post

    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. 

  2. Answer
    Fiko avatar
    1406 posts

    Posted 14 Jun 2010 Link to this post

    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.
Back to Top