ASP.NET
  Home arrow ASP.NET arrow Page 3 - Working with ADO.NET Datasets and .NET Obj...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Working with ADO.NET Datasets and .NET Objects using Crystal Reports and ASP.NET 2.0
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 15
    2007-08-06

    Table of Contents:
  • Working with ADO.NET Datasets and .NET Objects using Crystal Reports and ASP.NET 2.0
  • Adding a strongly typed dataset to the project: designer code
  • Binding the Crystal Report with a strongly typed dataset
  • .NET objects as data sources to Crystal Reports: adding an entity class
  • .NET objects as data sources to Crystal Reports: adding a collection class
  • .NET objects as data sources to Crystal Reports: adding and binding a crystal report

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with ADO.NET Datasets and .NET Objects using Crystal Reports and ASP.NET 2.0 - Binding the Crystal Report with a strongly typed dataset


    (Page 3 of 6 )

    Once the dataset and Crystal reports are created, add a new web form (DatasetDemo01.aspx) to the project, and then drag and drop a button and CrystalReportViewer Control.

    Make sure that the source behind looks like the following:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="DatasetDemo01.aspx.vb" Inherits="DatasetDemo01" %>

     

    <%@ 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>

          <asp:Button ID="Button1" runat="server" Text="Button" />

          <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />

        </div>

        </form>

    </body>

    </html>

    In the code behind, copy the following code:

    Imports CrystalDecisions.Shared

    Imports CrystalDecisions.CrystalReports.Engine

    Imports System.Data.SqlClient

    Imports System.Data

     

    Partial Class DatasetDemo01

        Inherits System.Web.UI.Page

     

      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        CrystalReportViewer1_Navigate(Nothing, Nothing)

      End Sub

     

      Protected Sub CrystalReportViewer1_Navigate(ByVal source As Object, ByVal e As CrystalDecisions.Web.NavigateEventArgs) Handles CrystalReportViewer1.Navigate

        Dim dt As New Orders.OrdersDataTable

        Dim ad As New SqlDataAdapter("SELECT TOP 200 OrderID, OrderDate, CustomerID, EmployeeID FROM orders", "Data Source=.sqlexpress;initial catalog=Northwind;user id=sa; password=eXpress2005")

        ad.Fill(dt)

        Dim rep As New ReportDocument

        rep.Load(Server.MapPath("DatasetDemo01.rpt"))

        rep.SetDataSource(CType(dt, DataTable))

        Me.CrystalReportViewer1.ReportSource = rep

        Me.CrystalReportViewer1.DataBind()

      End Sub

    End Class

    You may have to modify the connection string so that it connects to your server.  Finally, set the start page as DatasetDemo01.aspx, execute the application and hit the button to view the report.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hello guys,This is my third article focusing on "Programming with Crystal...
       · Hi,how we can use .net objects in crystal reports.
       · i have a question,how can we add .net objects and align them in the designer...
       · Hi, the tutorial works fine with only one datasource and one .xsd but when I try to...
     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek