Click here to Skip to main content
5,790,650 members and growing! (17,560 online)
Email Password   helpLost your password?
Web Development » ASP.NET » General     Intermediate

Crystal Reports PUSH method using ASP.NET

By Omkar Bhave M

This article explains how to use PUSH method for drawing reports.
C#, Windows, .NET 1.0, .NET, Visual Studio, ASP.NET, Dev

Posted: 21 Mar 2003
Updated: 21 Mar 2003
Views: 313,680
Bookmarked: 60 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
48 votes for this Article.
Popularity: 5.54 Rating: 3.30 out of 5
10 votes, 20.8%
1
6 votes, 12.5%
2
7 votes, 14.6%
3
10 votes, 20.8%
4
15 votes, 31.3%
5

Introduction

This article explains how to use PUSH method for drawing reports. It will also explain how to use user DataSets in an ASP.NET page for reports. There are two types of methods for drawing the reports:

  1. PULL method- the crystal report makes connection with the database, brings the fields data and draws the report.
  2. PUSH method- we create the DataSet, choose fields of the DataSet as report fields and then push it to the crystal report. Here I am going to explain the PUSH method only.

Steps

  1. Create a new ASP.NET project.

    Sample screenshot

  2. Insert new item as DataSet.

    Sample screenshot

  3. Add elements to the DataSet which you want on the report. Save All, then right click on the DataSet filename in the solution explorer and select command "Build and browse".
  4. Then add a new item to the project as “Crystal report” and insert a blank report.
  5. In the server explorer, right click database field and select database expert and expand the project data and select DataSet in the table selector and press OK.

    Sample screenshot

  6. Then drag the fields from the database fields of server explorer in the detail section of the report. Arrange the fields as you want.

    From the toolbox, add crystal report viewer control on to the page. That will add this variable:

    protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
  7. Populate the DataSet. Set the report DataSource and CrystalReportViewer report source.
    private void Page_Load(object sender, System.EventArgs e)
    {
    CrystalReport1 report=new CrystalReport1();
    CrystalReportViewer1.Visible=true;
    DataSet ds=new DataSet("Account");//give same name as on 
    
    //dataset1 table header
    
    DataTable table=new DataTable("Account");//give same name as on 
    
    //dataset1 table header 
    
    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$";
    // add to table
    
    table.Rows.Add(row);
    ds.Tables.Add(table);
    // set report's dataset
    
    report.SetDataSource(ds);
    // set report source
    
    CrystalReportViewer1.ReportSource =report;
    }

    The output will be as follows...

    Sample screenshot

Points to be careful of

  1. Give same names on Dataset and the table element name of inserted DataSet.
  2. As and when you modify DataSet, build it again and log off the current connections in report. Set the DataSource location again pointing to new DataSet, otherwise database fields of the report will not take the change.
  3. Setting up DataBind properties of the report viewer can be avoided. It can be done at runtime.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Omkar Bhave M


my name is omkar bhave. I work in Autodesk Inc. USA.
Occupation: Software Developer (Senior)
Company: Autodesk Inc.
Location: United States United States

Other popular ASP.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 59 (Total in Forum: 59) (Refresh)FirstPrevNext
QuestionSet Formula field in Crystal reportmemberbiswajit nayak23:52 15 Nov '08  
GeneralCrystal reportmemberAmit S Manekar0:06 3 Oct '08  
Generalcant access the crystalReportmemberSlick6912:27 4 Sep '08  
GeneralHow to Connect Crystal Report with SQL Server 2000 in VB.Net/memberemrugesh7:37 18 Aug '08  
GeneralCan anyone tell me how to upload ASP.NET application with Crystal report on WEBmemberAmit Papriwal23:14 10 Jul '08  
QuestionCrystal Report in asp.net 2005 Facing ProblemmemberGIRISH KUMAR PRAJAPATI20:30 9 Jun '08  
GeneralHow to set a fixed height of Crystal report in asp.netmemberJhanvy Thaker22:53 7 May '08  
Questionplease helpmembermuthumani1:02 12 Feb '08  
QuestionASP to crystal Reports .rpt NEED HELPmembermjelin10:10 26 Apr '07  
GeneralQuestion adout PUSH modelmemberDerrick Lasantha0:41 12 Mar '07  
GeneralRe: Question adout PUSH modelmemberjaimeaye22:20 1 May '07  
QuestionQuestionmembericeborg5:03 24 Jan '07  
AnswerRe: Questionmemberomkar bhave M12:16 24 Jan '07  
Questionicons missing when report is runmembertechie_risa20:39 8 Jan '07  
AnswerRe: icons missing when report is runmembersylvesterg5:17 24 Jan '07  
AnswerRe: icons missing when report is runmemberprabodhbansal2:07 5 Feb '07  
GeneralHelp , asp.net 1.0 with crystal reportmemberbeginhs17:58 11 Oct '06  
QuestionCannot get specific Line of codememberGaurav Rathod21:34 17 Jul '06  
GeneralHELPmembermalemsteen1:00 2 Jul '06  
GeneralLogon ProblemmemberMuneeeb22:00 13 Apr '06  
GeneralKeyup in datagrid in vb.netsussAnonymous1:48 6 Aug '05  
GeneralCrystal report In asp.netsussAnonymous1:40 6 Aug '05  
GeneralPage Scrolling in Crystal Reports 11 .NETsussbabukabraham@yahoo.com6:00 13 Jun '05  
GeneralCreating Report DynamicallymemberDronik23:34 10 Apr '05  
GeneralGood Articlemembernorm.net5:33 6 Apr '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 21 Mar 2003
Editor: Smitha Vijayan
Copyright 2003 by Omkar Bhave M
Everything else Copyright © CodeProject, 1999-2009
Web12 | Advertise on the Code Project