Right click on website name in solution explorer and select ADD NEW ITEM from that select DATASET.
Always give meaningful name to your dataset because we need to refer the same in our code, here I’ve given “DS_Northwind”
After that, Add Table adapter s in the DATASET. Here also we have to give meaningful name for our Table adapter, Data Table and for the Method
Save the Dataset and now we have our DataSet. Now we have to add a crystal report and a webform to our project.
Add crystal report from the templateand give report name accordingly.
Click “ADD” button. Now you’ll see the following screen.
Accept the default setting and click OK. From there we’ll point out our Dataset for report’s source
Select “ADO.NET Datasets” as your project Data and select the dataset what we created early Now press “>”and click Finish. You can click next too to select fields to display in the report. At this time we are going to do that manually.
From field explorer, add required field into your report and set space accordingly.
Now we are going to add chart into our report. Selectchart from the toolbar
After clicking this you’ll get chart construction panel. See the fig.
Select chart type and press the DATA Tab to define values for chart
I used Product Name and the unit price as my Data for the chart.We can change caption, series heading etc in TEXT tab. Now click ok.
Now we need to place the fields from database field to our report by dragging them to our report. The heading will be changed further meaningfull otherwise it shows the Database
field name by default.
Now I added the database fields and changed the Heading.
Now we need to add web form to display the report.
Add Crystal Report viewer into the added web form.
This is the aspx page code (HTML Markup) :<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%><%@RegisterAssembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"Namespace="CrystalDecisions.Web"TagPrefix="CR"
%><!DOCTYPEhtmlPUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>Untitled Page</title></head><body><form
id="form1"runat="server"><div><CR:CrystalReportViewerID="crviewer"
runat="server"AutoDataBind="true"/></div></form></body></html>
This is the ASPX.CS page(Code Page)
using System;using
System.Data;using System.Configuration;using
System.Web;using System.Web.Security;using
System.Web.UI;using System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using
CrystalDecisions.Shared;using CrystalDecisions.CrystalReports;using
CrystalDecisions.CrystalReports.Engine;using DS_NorthwindTableAdapters;
// include our dataset herepublicpartialclass
_Default : System.Web.UI.Page{protectedvoid Page_Load(object sender,
EventArgs e){TA_Products products =
newTA_Products();DataTable DT_products =
newDataTable();ReportDocument RptDocument =
newReportDocument();RptDocument.Load(Server.MapPath("Products.rpt"));RptDocument.SetDataSource(DT_products);crviewer.ReportSource = RptDocument;crviewer.DataBind();}}Now run You get
Happy
programming.
asp.net 2.0Crystal Report Using DataSetCrystal report C#
None
0 Points
1 Post
Creating Crystal report using DataSet
Mar 23, 2008 10:15 AM|Stalin.VG|LINK
Creating Crystal Report in ASP.NET with DataSet
First we need to create a DataSet
Right click on website name in solution explorer and select ADD NEW ITEM from that select DATASET.
Always give meaningful name to your dataset because we need to refer the same in our code, here I’ve given “DS_Northwind”
After that, Add Table adapter s in the DATASET. Here also we have to give meaningful name for our Table adapter, Data Table and for the Method
Save the Dataset and now we have our DataSet. Now we have to add a crystal report and a webform to our project.
Add crystal report from the template and give report name accordingly.
Click “ADD” button. Now you’ll see the following screen.
Accept the default setting and click OK. From there we’ll point out our Dataset for report’s source
Select “ADO.NET Datasets” as your project Data and select the dataset what we created early Now press “>” and click Finish. You can click next too to select fields to display in the report. At this time we are going to do that manually.
From field explorer, add required field into your report and set space accordingly.
Now we are going to add chart into our report. Select chart from the toolbar
After clicking this you’ll get chart construction panel. See the fig.
Select chart type and press the DATA Tab to define values for chart
I used Product Name and the unit price as my Data for the chart. We can change caption, series heading etc in TEXT tab. Now click ok.
Now we need to place the fields from database field to our report by dragging them to our report. The heading will be changed further meaningfull otherwise it shows the Database field name by default.
Now I added the database fields and changed the Heading.
Now we need to add web form to display the report.
Add Crystal Report viewer into the added web form.
This is the aspx page code (HTML Markup) :<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <CR:CrystalReportViewer ID="crviewer" runat="server" AutoDataBind="true" /> </div> </form></body></html>This is the ASPX.CS page(Code Page)
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using CrystalDecisions.Shared;using CrystalDecisions.CrystalReports;using CrystalDecisions.CrystalReports.Engine;using DS_NorthwindTableAdapters; // include our dataset herepublic partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { TA_Products products = new TA_Products(); DataTable DT_products = new DataTable(); ReportDocument RptDocument = new ReportDocument(); RptDocument.Load(Server.MapPath("Products.rpt")); RptDocument.SetDataSource(DT_products); crviewer.ReportSource = RptDocument; crviewer.DataBind(); }} Now run You get Happy programming.asp.net 2.0 Crystal Report Using DataSet Crystal report C#
www.anadocs.com