An item with same key has already been added

7 posts, 1 answers
  1. BC
    BC avatar
    24 posts
    Member since:
    Nov 2009

    Posted 04 Feb 2010 Link to this post


    I have installed Reporting Q3 2009 on Windows 7 and using it in VS 2008, SQL 2005 and .Net 3.5 environment. I have created Reports class library and created a report which runs fine when I previewed it. However, when I added it to the web project, I keep getting "an item with the same key has already been added" on the line below
                RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null);
    I have used ReportViewer and also tried exporting programmatically to PDF format.

    Any help is greatly appreciated.

  2. Answer
    Peter avatar
    1629 posts

    Posted 04 Feb 2010 Link to this post

    Hi Bhargavi Chukkapalli,

    This is a generic .NET error that is not directly related to Telerik Reporting and you can find numerous threads on it in various scenarios. In the context of Reporting, it could happen when you try to add two or more items with the same ID/Name e.g. you have a textbox (textBox1) and in your code you try to add another one with the same name.
    Please review your code and if you are unable to find the duplicate, send us a sample runnable project that replicates the issue.

    Kind regards,
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. BC
    BC avatar
    24 posts
    Member since:
    Nov 2009

    Posted 26 Feb 2010 Link to this post


    Thanks for your response. I tried your suggestion checking for any duplicate names and could not find anything in that area. However, I was able to resolve by changing the way report parameters are assigned inside the aspx code. I was creating a report parameter object and setting it's name, value and then assigning it to the report. For some reason this was the cause of the error I was receiving. I changed to do it all in one line like below and the issue got resolved.           

    reportDoc.ReportParameters["PDID"].Value = this.PDID;

  4. MGrassman
    MGrassman avatar
    92 posts
    Member since:
    Apr 2007

    Posted 31 Aug 2010 Link to this post

    I had this same error when I upgraded to 2010 Q2.  Q1 worked just fine with the same report.  the problem ended up being I was using a report book and the paramaters were the same for both reports.  I went in and changed the paramters on one of the reports and and everything worked fine. 

    Should I have set the parameters differently in the report book?

    ReportViewer1.Visible = districtRecId.ToString() != "0";
                BPB.Reports.DistrictStatsFSDView headerReport = new BPB.Reports.DistrictStatsFSDView();
                headerReport.ReportParameters["DistrictRecId1"].Value = districtRecId;
                headerReport.ReportParameters["BudgetYearGroup1"].Value = Convert.ToInt32(ConfigurationManager.AppSettings["BudgetYearGroup"].ToString());
                BPB.Reports.FSDBusinessPlan detailsReport = new BPB.Reports.FSDBusinessPlan();
                detailsReport.ReportParameters["DistrictRecId"].Value = districtRecId;
                detailsReport.ReportParameters["BudgetYearGroup"].Value = BudgetYearGroup;
                ReportBook reportBook = new ReportBook();
                ReportViewer1.Report = reportBook;
  5. Steve
    Steve avatar
    10941 posts

    Posted 02 Sep 2010 Link to this post

    Hi MGrassman,

    As noted in the Report Book documentation, Telerik Reporting provides a mechanism known as parameter merging. The rule for merging parameters is straightforward - if the Name and Type of two (or more) parameters from different reports are the same, then they are considered equivalent and are displayed as a single parameter in the parameters area.
    So having the same parameters in two different reports should definitely not cause such problems and we were not able to reproduce such behavior. However a somehow related issue was fixed in the latest internal build, when you use the same report several times in a report book with different value of a parameter and this parameter was marked as Mergable=false, but according to your code this is not the case.

    Sincerely yours,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Michael weinberger
    Michael weinberger avatar
    17 posts
    Member since:
    Aug 2005

    Posted 30 Dec 2010 Link to this post

    I have found another reason for that error in latest release.
    If your dataset contains two columns with the same name (like Table1.Id, Table2.Id, without aliases) you get the same error when trying to see report or even preview the dataset.

    Other reporting solutions prefixes the extra fields like Id1, etc. At least a better error message should be there :-)

  7. Preston
    Preston avatar
    1 posts
    Member since:
    Oct 2010

    Posted 20 Jan 2011 Link to this post

    This was exactly the problem for me. I was using an ID as one of the report parameters, and the stored procedure was returning the same id twice in the join. 

    Thanks for the post!
Back to Top