none
Report (rdlc) in Visual Studio 2010 (C#) RRS feed

  • Question

  • Hi,

    I am trying to get a grasp of the report designer in Visual Studio 2010 (.rdlc). I've drawn a ReportViewer on the form, which created a BindingSource object for me. I've attacted Report1.rdlc (using the wizard also created the dataset too) to the ReportViewer and did the following code:

    The data comes is the business objects from my class described below.

    //==============
    // I did the following class for the data
    //==============

    public class MyClass
    {
        public string DataType{get;set;}  // for report grouping
        public string SomeData{get;set;}  // Details data

        public List<MyClass> GetData()
        {
    int i =0;

    List<MyClass> cls = new List<MyClass>();

    for (i=1 ; i<=5 ; i++)
    {
      cls.Add(new MyClass(){ DataType='Grp1',SomeData="G1 Data " + i.ToString()});
    }

    for (i=1 ; i<=5 ; i++)
    {
      cls.Add(new MyClass(){ DataType='Grp2',SomeData="G2 Data " + i.ToString()});
    }

    return cls;

        }

    }



    //--------
    // On a button click did the following
    //--------
    MyClass mc = new MyClass();
    this.<BindingSource>.DataSource  = mc.GetData();
    ReportViewer.ReportRefresh();



    I want the report to be grouped by DataType property and show the value of DataType in the group header in BOLD and SomeData value repeating in the detail. I am used to the traditional Page Header, Group Header, Details, Group Footer, Page Footer type of report designer layout.
    Not matter what I did, it did not generate the report as desired format. 

    Sample Report Format:



    Test Report

    -------------------------------------------------------
    Group Type = Grp1
    -------------------------------------------------------
    G1 Data 1
    G1 Data 2
    G1 Data 3
    G1 Data 4
    G1 Data 5

    -------------------------------------------------------
    Group Type = Grp2
    -------------------------------------------------------
    G2 Data 1
    G2 Data 2
    G2 Data 3
    G2 Data 4
    G2 Data 5

    Thank You,

    Mathew

    Wednesday, April 25, 2012 11:08 AM