6

In the below example I have a number of public classes that are defined in a namespace. These are going to be instantiated, bound to ReportDataSets and handed off to my ReportViewer control to generate a report from my report definition files. When I try to access these classes in the Report Data window of the report designer for my .RDLC files, however, it only shows a few of the classes I've defined. What's going on, where are all the rest?

namespace Namespace1
{
    public class Class1
    {
        public string String1 { get; set; }
    }

    public class Class2
    {
        public string String1 { get; set; }
    }
}

Note: If you try to add the Class1 definition to the report page that requires Class2's data and then bind Class2 to the ReportDataSet before the report is generated, an exception will be thrown.

Brandon Arnold
  • 410
  • 1
  • 5
  • 18
  • how about showing some code so someone can see if in fact you did something wrong – MethodMan Jan 20 '13 at 23:19
  • @DJKRAZE: Did you notice that I wrote this in Q&A mode and included code in the answer? – Brandon Arnold Jan 20 '13 at 23:28
  • Brandon also what exception is being thrown..? – MethodMan Jan 21 '13 at 00:06
  • Glad to see a couple of people are finding this Q&A helpful and it was re-opened, seeing as how unfair @DJKRAZE and others were to shut it down. This Visual Studio bug cost me and a workmate many hours to track down, and it's still in the 2013 version. – Brandon Arnold Feb 06 '14 at 14:58

1 Answers1

3

When there are a number of classes with the same schema (all properties and their datatypes are the same), only the one that's first alphabetically will show up. But both will show up in the below example, because they do not have the same name for all properties (in this case, the one string).

namespace Namespace1
{
    public class Class1
    {
        public string String1 { get; set; }
    }

    public class Class2
    {
        public string String2 { get; set; }
    }
}
Brandon Arnold
  • 410
  • 1
  • 5
  • 18