Hi,
This is the code which is used for ReportViewer 2008 and i need code for ReportViewer 2010.
so please help me out asap.
private void CustomizeReportViewer(System.Web.UI.Control reportControl)
{
foreach (System.Web.UI.Control childControl in reportControl.Controls)
{
if (childControl.GetType() == typeof(System.Web.UI.WebControls.DropDownList))
{
System.Web.UI.WebControls.DropDownList ddList = (System.Web.UI.WebControls.DropDownList)childControl;
if (ddList.ToolTip.Contains("Export"))
{
ddList.PreRender += new EventHandler(ddList_PreRender);
}
}
if (childControl.GetType() == typeof(System.Web.UI.WebControls.Button))
{
System.Web.UI.WebControls.Button ddList = (System.Web.UI.WebControls.Button)childControl;
if (ddList.UniqueID.Contains("ctl00_ContentPlaceHolder1_rptviewerByBrandBySentimentAttribute_ctl06_ctl04_ctl00_Button"))
{
ddList.PreRender += new EventHandler(ddList_PreRender);
}
}
if (childControl.Controls.Count > 0)
{
CustomizeReportViewer(childControl);
}
}
}
// This is the event handler added from CustomizeRV
// We just check the object type to get what we needed.
// Once the dropdownlist is found, we check if it is for the ExportGroup.
// Meaning, the "Excel" text should exists.
// Then, just traverse the list and disable the "Excel".
// When the report is shown, "Excel" will no longer be on the list.
// You can also do this to "PDF" or if you want to change the text.
void ddList_PreRender(object sender, EventArgs e)
{
if (sender.GetType() == typeof(System.Web.UI.WebControls.DropDownList))
{
System.Web.UI.WebControls.DropDownList ddList = (System.Web.UI.WebControls.DropDownList)sender;
System.Web.UI.WebControls.ListItemCollection listItems = ddList.Items;
if ((listItems != null) && (listItems.Count > 0) && (listItems.FindByText("Excel") != null))
{
foreach (System.Web.UI.WebControls.ListItem list in listItems)
{
if (list.Text.Equals("XML file with report data") || list.Text.Equals("CSV (comma delimited)") || list.Text.Equals("TIFF file") || list.Text.Equals("Word") || list.Text.Contains("PPS"))
{
list.Enabled = false;
}
}
}
}
}
susana w