Hi nauna,
I have created sample that full fill your requirement.
HTML
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Hide Export Option:
<asp:RadioButtonList runat="server" ID="rbExportOptions" RepeatDirection="Horizontal"
AutoPostBack="true" OnSelectedIndexChanged="rbExportOptions_SelectedIndexChanged">
<asp:ListItem Text="None" Value="None" />
<asp:ListItem Text="Excel" Value="Excel" />
<asp:ListItem Text="PDF" Value="PDF" />
<asp:ListItem Text="Word" Value="Word" />
</asp:RadioButtonList>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="600">
</rsweb:ReportViewer>
Code
string exportOption;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rbExportOptions.SelectedIndex = 0;
BindReport();
}
exportOption = rbExportOptions.SelectedItem.Text.Trim();
}
private void BindReport()
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
Customers dsCustomers = GetData("select top 20 * from customers");
ReportDataSource datasource = new ReportDataSource("Customers", dsCustomers.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
}
private Customers GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlCommand cmd = new SqlCommand(query);
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (Customers dsCustomers = new Customers())
{
sda.Fill(dsCustomers, "DataTable1");
return dsCustomers;
}
}
}
}
public void DisableExportOption(ReportViewer ReportViewerID, string strFormatName)
{
exportOption = rbExportOptions.SelectedItem.Text.Trim();
foreach (RenderingExtension extension in ReportViewerID.LocalReport.ListRenderingExtensions())
{
if (extension.Name.ToLower() == strFormatName.ToLower())
{
FieldInfo info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
info.SetValue(extension, false);
}
}
}
public void RefreshReport(ReportViewer ReportViewerID)
{
ReportViewerID.Reset();
BindReport();
}
protected void rbExportOptions_SelectedIndexChanged(object sender, EventArgs e)
{
RefreshReport(ReportViewer1);
DisableExportOption(ReportViewer1, exportOption);
}
Screenshot