How to disable (hide) specific Export Button from RDLC ReportViewer in ASP.Net

Last Reply on Dec 09, 2014 08:57 AM By Azim

Posted on Dec 06, 2014 05:45 AM

Mr.Mudassar

 

pls help me to disable excel export in Reportviewer(rdlc) dropdown menu is asp.net page using vb code

Thank you.

 maideen

Posted on Dec 06, 2014 06:05 AM

1. Add OnLoad event handler to the ReportViewer.

 OnLoad = "ReportViewer_OnLoad"

2. And the use the following code

protected void ReportViewer_OnLoad(object sender, EventArgs e)
{
    RenderingExtension extension = ReportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals("Excel", StringComparison.CurrentCultureIgnoreCase));
    System.Reflection.FieldInfo info = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    info.SetValue(extension, false);
}