0

When I pass the dataset as an explicit interface, instead of implicit, the fields are blank. I can't figure out why the explicit interface calls don't work, while the implicit does. I am able to see all the fields in the report viewer wizard to drag the 'fields' to the display as placeholders. But they are displayed as blank when the program runs.

Classes:

public class MyReportData : IMyReportData
{
    string IMyReportData.Field1 { get; set; }
    string IMyReportData.Field2 { get; set; }
}

public class TestData : ITestData
{
    public string MyTest { get; set; }
    public string MyTest2 { get; set; }
}

When passed to the report viewer:

IMyReportData data = new MyReportData();
data.Field1 = "Field 1";
data.Field2 = "Field 2";
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", new List<IMyReportData>() { data }));

ITestData test = new TestData;
test.MyTest = "Test 1";
test.MyTest2 = "Test 2";
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", new List<ITestData >() { test}));

The data in 'test' displays. But the data in 'data' is empty in the report.

Kelsey
  • 43
  • 2
  • 12
  • 1
    Does this help? https://stackoverflow.com/questions/143405/c-sharp-interfaces-implicit-implementation-versus-explicit-implementation --Hint, I don't think `data` is being casted to `IMyReportData` when added to the list. – claylong Oct 26 '17 at 20:06
  • @ClayLong, so Report Viewer sees the properties as private? That's why it doesn't display them? If so, then I am still a little confused. As I can see then properties in the Report Data toolbar when I am creating the report. So my follow up question is how does it know they exist but cannot reach the data they contain? – Kelsey Oct 26 '17 at 20:54
  • I'm starting to suspect the report viewer might use Reflection to access the data source. If so, the implementation may not be sophisticated enough to property handle your scenario. Trying to experiment with this now, but no promises. – claylong Oct 27 '17 at 13:28

0 Answers0