Skip to Content
0
Former Member
May 17, 2010 at 11:24 PM

CRVS2010 Beta - C# objects as DataSource

20 Views

Are there any examples of using C# objects as a report datasource? I've tried to follow the slightly outdated tutorial in the help docs, applied to my own project, but all I come up w/ is a blank report (except for static text fields). The primary problem is that the marked classes don't seem to show up in the field selector, only instantiated objects.

Here's a code snippet, if that helps - The list elements, which are inserted into the report in the details section, is correctly populated but nothing appears.

private void ConfigureCrystalReports()

{

// Create the list object on which to report

PopulateCRLstReqSlcts();

try

{

crRepDocthis = new ReportDocument();

crRepDocthis.Load(@"...\CrystalReportSMLTest.rpt");

crRepDocthis.SetDataSource(DataBridge.instanceDataBridge.LstReqSlcts);

crystalReportsViewer1.ViewerCore.ReportSource = crRepDocthis;

}

catch(Exception ex)

{

string strThis = "Viewer Load Failed " + ex.Message;

MessageBox.Show(strThis);

}

}

public void PopulateCRLstReqSlcts()

{

// Create a new LstReqSlcts object and initialize it

// Initialize requirement list

DataBridge.instanceDataBridge.FillReqSlcts(DataBridge.instanceDataBridge.GetAllReqSlct());

}

// and some of my objects....

public partial class DataBridge

{

// Items for the Requirement Selector list box

public class ReqSlct

{

public ReqSlct()

{

}

public ReqSlct(int nRSIDThis, string strRSNamThis)

{

this.ReqSlctID = nRSIDThis;

this.strReqSlctNam = strRSNamThis;

}

public int ReqSlctID { get; set; }

public string strReqSlctNam { get; set; }

public override string ToString()

{

return strReqSlctNam;

}

}

[CrystalDecisions.CrystalReports.Engine.CrystalComplexTypeExpansionLevels(3)]

public List<ReqSlct> LstReqSlcts { get; set; }