How to add a dynamic table to a Crystal ReportViewer? RRS feed

  • Question

  • User921007156 posted

    Hi All,

    I'm trying to create my first crystal report, but I want to create the data dynamically. I want to create my table on the fly then, just dump the table into the crystal report.

    1. I'm not sure how to setup the fieldnames in the report to point to my dynamic table.

    2. How do I add the columns name in my dynamic table to my report?

            DataTable m_tExample = new DataTable();

            // Add Column Names
            m_tExample.Columns.Add("firstname", typeof (string));
            m_tExample.Columns.Add("lastname", typeof( string));

            // Add Test Data
            m_tExample.Rows.Add("D", "Chiat");
            m_tExample.Rows.Add("Matdt", "Sdmith");
            m_tExample.Rows.Add("Kevin", "Cloley");
            m_tExample.Rows.Add("Maitt", "Diurkee");
            m_tExample.Rows.Add("Paam", "Duurkee");
            m_tExample.Rows.Add("William", "Never");
            m_tExample.Rows.Add("Tang", "Hong");
            m_tExample.Rows.Add("Mike", "Lopez");
            m_tExample.Rows.Add("Bill", "Chao");
            m_tExample.Rows.Add("Az", "Mattizra");
            m_tExample.Rows.Add("Raja", "Crash");
            m_tExample.Rows.Add("Jimmy", "Compton");
            m_tExample.Rows.Add("Ray", "Johnson");
            m_tExample.Rows.Add("Janice", "Howard");
            m_tExample.Rows.Add("Tony", "Scott");
        // Add DataSet to Viewer?
            CrystalReportViewer1.ReportSource = m_tExample.DataSet;

    NOTE: When I'm in the designer, I only see a text object to place in the report detail for a fieldname.


    Wednesday, September 21, 2011 7:53 PM

All replies