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

How to call RadGrid.MasterTableView.ExportToExcel() from RadMenu?

2 Answers 182 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Bernhard
Top achievements
Rank 2
Bernhard asked on 10 Mar 2010, 06:07 PM
Hi,

in the Master I have a Rad menu, which gets the items from a siteMap-File
<telerik:RadMenu ID="radMenu" runat="server"      
 DataSourceID="siteMapDataSource" onitemclick="radMenu_ItemClick" /> 

In the method radMenu_ItemClick I tried to get a reference to the RadGrid in the current Page. (I assume here that the correct page is currently loaded)
protected void radMenu_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)  
   {  
      Tasklist tasklistGUI = radMenu.Page as Tasklist;  
      RadGrid tasklistRadGrid = tasklistGUI.FindControl("RadGrid1"as RadGrid;  
      tasklistRadGrid.MasterTableView.ExportToExcel();  
   } 

The idea is then to call ExportToExcel as a method of the referenced object. But the object is null!
What's wrong? What must I do to get a working reference to the RadGrid?

Thank you very much in advance.

Regards
Bernhard

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 11 Mar 2010, 11:26 AM
Hi,

You can access  the RadGrid from the ContentPlaceholder of the Master page which will hold the contents  as shown below:

C#
 protected void radMenu_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e) 
    { 
        RadGrid tasklistRadGrid = ContentPlaceHolder1.FindControl("RadGrid1"as RadGrid; 
        tasklistRadGrid.MasterTableView.ExportToExcel(); 
    }  


Princy
0
Bernhard
Top achievements
Rank 2
answered on 11 Mar 2010, 11:46 AM
Hi Princy,

this exactly has solved my problem.
Many Thanks!

Regards
Bernhard
Tags
Menu
Asked by
Bernhard
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Bernhard
Top achievements
Rank 2
Share this question
or