Loading ...

how to change the chart type with reportViewer in VS2010

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  visual studio   » how to change the chart type with reportViewer in VS2010

how to change the chart type with reportViewer in VS2010

Posts under the topic: how to change the chart type with reportViewer in VS2010

Posted: 8/23/2010

Lurker 10  points  Lurker
  • Joined on: 8/23/2010
  • Posts: 2

hi, i want to change the chart type of the chart in a rdlc file with the reportViewer using
vs2010 ,i thought  it's important to find the ChartType node in the rdlc xml file ,but there is  no the nodes that can represent the chartType property.  so i have no idea now ,Can you
have any solution ?

this effect is lie that

code snippet

  /// Replaces the chart type in the report with the chart type passed to this method.
  /// </summary>
  /// <param name="documentToUpdate">The report.rdlc (xml document) you want to change the chart type for.</param>
  /// <param name="desiredChartType">The desired chart type, don't worry about blank strings, it is set to a default in the function.</param>
  /// <param name="reportNamespace">The namespace of the report.  You can find this by opening your .rdlc file in an xml browser.</param>
  /// <param name="listName">The name of the list object that you included in your report.  If your components are not using a list, pass null.</param>
  /// <param name="chartName">The name of the chart you want to adjust the type for.</param>
  /// <param name="viewerToUpdate">The ReportViewer object you are going to add this report to.</param>
        public  void UpdateReportChartType(XmlDocument documentToUpdate, string desiredChartType, string reportNamespace, string listName, string chartName,
          ReportViewer viewerToUpdate,DataTable dt)
        {
            XmlElement root = documentToUpdate.DocumentElement;
            XmlNamespaceManager nsManager = new XmlNamespaceManager(documentToUpdate.NameTable);
            nsManager.AddNamespace("ns", reportNamespace);
            XmlNode workingNode;
            //If component does not use a list, leave out the list item by making the list string blank.
            string listToUse;
            if ((listName == null) || (listName == ""))
                listToUse = "";
            else
                listToUse = "ns:ReportItems/ns:List[@Name='" + listName + "']/";
            //Set the chart type.
            workingNode = root.SelectSingleNode("ns:Body/" + listToUse + "ns:ReportItems/ns:Chart[@Name='" + chartName + "']/ns:Type", nsManager);       
//this code is making error //because the type node was  never found ;
            if (desiredChartType == "")
                workingNode.InnerText = "Column";
            else
                workingNode.InnerText = desiredChartType;
            //Save original settings to restore after resetting.
            ProcessingMode originalProcessingMode = viewerToUpdate.ProcessingMode;
            ReportDataSource originalDataSource = new ReportDataSource("UserPages_Data", dt);
            //Reset the basic report information.
            viewerToUpdate.Reset();
            viewerToUpdate.ProcessingMode = originalProcessingMode;
            viewerToUpdate.LocalReport.DataSources.Add(originalDataSource);
            viewerToUpdate.LocalReport.ReportPath = string.Empty;
            viewerToUpdate.LocalReport.LoadReportDefinition(new StringReader(documentToUpdate.OuterXml));
            viewerToUpdate.LocalReport.Refresh();
        }


 if it is possible ,please connect  me ,that's very hurry .

thanks


Posted: 9/1/2010

Professional 8505  points  Professional
  • Joined on: 5/3/2010
  • Posts: 391
  Answered

Hello @hu Zuria and Welcome to CodeASP.NET Community.

I have passed through your code and have seen similar question asked previously in the MSDN forums, probably this link: http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/f4f44a2f-3d50-4885-8893-8148c39c9c30 of the conversation there might help you.

Regards,
Hajan


Posted: 9/8/2010

Lurker 10  points  Lurker
  • Joined on: 8/23/2010
  • Posts: 2

hello,

 I'm sorry i read your reply  today ,and  thank you for your reply

but i have read the articles  from your link ,that is not work

these ways are effective in vs 2008 or vs 2005

but in vs2010 the rdlc  xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">;

there is no "Type" tagName in the chart part in RdlcXml2008NameSpace,

so i want to look for other methods .

 

Regards,

 Hu zuria

 


Page 1 of 1 (3 items)