locked
Dynamically building a table RRS feed

  • Question

  • User-782651317 posted

    Hello everyone,

    I have to display a table on my RPT. I know that I want to display 8 columns but don't know the rows. Plus, I can't get them directly from DB using an SP. I have to do calculations/manipulations in code-behind to come up with their values.

    The approach that I'm using so far is that I have created a dummy SP that returns 8 'String' variables; these become my 8 columns e.g. named as Field01, Field02 ... Field08. In code-behind I know that how many rows are to be displayed, assume 2 rows are to be displayed. I do the following:

    //Creat an object of RPT file
    MyRPT myRPT = new MyRPT();
    
    //DataTable to be used as DataSource
    DataTable dt = new DataTable();
    DataRow drow;
    
    dt.Columns.Add("Field01", System.Type.GetType("System.String"));
    dt.Columns.Add("Field02", System.Type.GetType("System.String"));
    dt.Columns.Add("Field03", System.Type.GetType("System.String"));
    dt.Columns.Add("Field04", System.Type.GetType("System.String"));
    dt.Columns.Add("Field05", System.Type.GetType("System.String"));
    dt.Columns.Add("Field06", System.Type.GetType("System.String"));
    dt.Columns.Add("Field07", System.Type.GetType("System.String"));
    dt.Columns.Add("Field08", System.Type.GetType("System.String"));
    
    //As per our assumption, this loop will execute twice adding two rows in the DataTable
    foreach (Object obj in objList)
    {
        drow = dt.NewRow();
        drow["Field01"] = obj.ToString();
    
        //Logic for the remaining seven fields is skipped
    
        dt.Rows.Add(drow);
    }
    
    myRPT.SetDataSource(dt);

    Now here I do get two rows in the DataTable but when the report is displayed, instead of showing two records on a single page it becomes a 2-pages report. First page shows the first record and the second shows the second record. How can I make it a 1-page multi-record report?

    Wednesday, November 23, 2011 2:14 AM

All replies

  • User-782651317 posted

    Please help me guys...

    Thursday, November 24, 2011 6:23 AM