This is a migrated thread and some comments may be shown as answers.

An item with same key has already been added

6 Answers 684 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
BC
Top achievements
Rank 1
BC asked on 04 Feb 2010, 12:39 PM
Hi,

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.

Thanks,
Bhargavi.

6 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 04 Feb 2010, 02:44 PM
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,
Peter
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.
0
BC
Top achievements
Rank 1
answered on 26 Feb 2010, 03:56 PM
Hi,

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;

0
MGrassman
Top achievements
Rank 2
answered on 31 Aug 2010, 09:55 PM
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();
            reportBook.Reports.Add(headerReport);
            reportBook.Reports.Add(detailsReport);
  
            ReportViewer1.Report = reportBook;
0
Steve
Telerik team
answered on 02 Sep 2010, 09:15 AM
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,
Steve
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
0
Michael weinberger
Top achievements
Rank 1
answered on 30 Dec 2010, 05:21 PM
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 :-)

Thanks
0
Preston
Top achievements
Rank 1
answered on 20 Jan 2011, 07:15 AM
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!
Tags
General Discussions
Asked by
BC
Top achievements
Rank 1
Answers by
Peter
Telerik team
BC
Top achievements
Rank 1
MGrassman
Top achievements
Rank 2
Steve
Telerik team
Michael weinberger
Top achievements
Rank 1
Preston
Top achievements
Rank 1
Share this question
or