How to set 3 datasources into one report

Сonversation on different topics
Post Reply
myintw
Posts: 29
Joined: Mon May 09, 2011 8:02 pm
Location: Perth

How to set 3 datasources into one report

Post by myintw »

Hi,

I am doing report using Stimulsoft and basically in my report, there is 3 dataTables. One is for course, one is for unit and another one is for assessment. But each of them has relation or link. Idea is one course may have units and assessments and also unit may have assessments. I want to display them in my report.

For example, my report would be like:

Course ID , Course Code , Course Name, Type
Assessment Name , Assessment Type <---- that would be optional (if it is available, it will be displayed)
Unit ID, Unit Code, Unit Name <---- that would be optional (if it is available, it will be displayed)
Assessment Name, Assessment Type <---- that would be optional (if it is available, it will be displayed)


All these data are from different datasources in my coding behind, I mean I get data for each of them from different datasources. My coding is like:

if (((IButtonControl)sender).CommandArgument == "Detailed")
{

DataSet dSet = new DataSet("CourseDetails");
DataTable output = new DataTable("RepCourse");
dSet.Tables.Add(output);

DataTable dtt = new DataTable("RepUnit");
dSet.Tables.Add(dtt);

output.Columns.Add("CourseId");
output.Columns.Add("CourseName");
output.Columns.Add("Type");
output.Columns.Add("CourseCode");
output.Columns.Add("Count", typeof(string));

dtt.Columns.Add("Unit");
dtt.Columns.Add("UnitCode");

foreach (GridDataItem gdi in GridView1.MasterTableView.Items)
{
foreach (GridFilteringItem filteritem in GridView1.MasterTableView.GetItems(GridItemType.FilteringItem))
{


DataTable dtCourseUnits = TMS_DAL.CourseUnitManager.GetAllCourseUnits(int.Parse(gdi["Id"].Text), null);

DataRow dr = output.NewRow();
DataRow drr = dtt.NewRow();


dr["CourseId"] = Convert.ToInt32(gdi["Id"].Text);
dr["CourseName"] = gdi["Name"].Text.Replace(" ", "");
dr["Type"] = gdi["Type"].Text.Replace(" ", "");
dr["CourseCode"] = gdi["Code"].Text.Replace(" ", "");

for (int i = 0; i < dtCourseUnits.Rows.Count; i++)
{

drr["Unit"] = dtCourseUnits.Rows["UnitName"].ToString();
drr["UnitCode"] = dtCourseUnits.Rows["UnitCode"].ToString();
dtt.Rows.Add(drr);

}

output.Rows.Add(dr);
}

}

StiReport sreport = new StiReport();
sreport.Load(HttpContext.Current.Server.MapPath("~\\Report\\Course_Details_Report.mrt"));

sreport.RegData(dSet);

sreport.Dictionary.Synchronize();
StiReportResponse.ResponseAsRtf(this.Page, sreport);
}

I tried this way and it doesn't work at all. In here, I didn't mention about Assessment for now because i am afraid it's a bit complicated to you. In my actual design, it's also included the assessment under course and unit. If you have better idea or way to solve this issue, please let me know how to do it. Thanks a lot for help in advance to Stimulsoft team. I really appreciate it for your help. If you need to have a look at my report design, just let me know.

Regards,
Win

Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to set 3 datasources into one report

Post by Alex K. »

Hello,

Please send us your project with report and sample data for analysis.

Thank you.
Post Reply