views:

610

answers:

1

Hello friends,

I'm creating a runtime dataset in page load. In this dataset I'm adding columns like that:

CrystalDecisions.CrystalReports.Engine.ReportDocument orpt = 
   new CrystalDecisions.CrystalReports.Engine.ReportDocument();

DataTable table = new DataTable("DataSet1");

table.Columns.Add("Fname", typeof(System.String));
table.Columns.Add("Lname", typeof(System.String));
table.Columns.Add("Salary", typeof(System.String));
DataRow row = table.NewRow();
row["Fname"] = "Mathew";
row["Lname"] = "Hayden";
row["Salary"] = "5000$";

table.Rows.Add(row);
ds.Tables.Add(table);

orpt.Load(MapPath("CrystalReport3.rpt"));
orpt.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = orpt;

Records are not displayed in CrystalReport3.rpt when I'm going to run the program. Please tell me how to set these coloums in Crystal Reports 3!

+1  A: 

What happens if you move your code from the Page_Load to the Page_Init event handler of the ASP.NET page?

Try to set the AutoDataBind property to "true":

Gets or sets whether automatic data binding to a report source is used. If the value is set to True, the DataBind() method is called after OnInit() or Page_Init() events.

Another tip: did you try to call the RefreshReport() (or Refresh() in older versions) method of your CrystalReportViewer1 object?

splattne