2012-04-19 4 views

risposta

8
+0

Grazie a Pranay ... Questi tutorial di base sono di aiuto per me ... –

+1

@SonamMohite - sei il benvenuto ... in attesa di voti positivi sulla mia risposta .. –

+0

Hey Pranay .... Innanzitutto grazie per avermi aiutato . C'è solo poca confusione sulla creazione di Dataset con Stored Procedures. Come ho lavorato bene con DataSet con Table quindi ora voglio provare questo. Puoi pubblicare il codice per questo. –

1

Il mio codice funziona per creare report per gli oggetti business class ...

Creazione di report con Classe Business Objects & ReportViewer (ASP.NET/ C#) 1.Creare Studente Classe

public class StudentClass 
    { 
     public int No { get; set; } 
     public string Name { get; set; } 
     public string Degree { get; set; } 
    } 

2.Creare Student repository con GetStudents() funzione

public class StudentRepository : StudentClass 
    { 
     public List<StudentClass> studentList = new List<StudentClass>(); 

     public List<StudentClass> GetStudents() 
     {    
      StudentClass student1 = new StudentClass(); 
      student1.No = 1; 
      student1.Name = "Bhuvana"; 
      student1.Degree = "M.Tech"; 
      studentList.Add(student1); 
      StudentClass student2 = new StudentClass(); 
      student2.No = 2; 
      student2.Name = "Annie"; 
      student2.Degree = "B.Tech"; 
      studentList.Add(student2); 
      StudentClass student3 = new StudentClass(); 
      student3.No = 3; 
      student3.Name = "Muthu Abi"; 
      student3.Degree = "B.Tech"; 
      studentList.Add(student3); 
      return studentList; 
     } 
    } 

3.Using report Wizard creare “StudentReport.rdlc” e selezionare DataSource

4.In Index.aspx aggiungere Script Manager e Visualizzatore Relazione Toolbox (drag and drop) Metodo

<div> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 
    <rsweb:ReportViewer ID="ReportViewer1" runat="server"> 
    </rsweb:ReportViewer>  
</div> 

5.Modify Page Load() nel codice dietro file di

public partial class Index : System.Web.UI.Page 
{ 
    StudentRepository sr = new StudentRepository(); 
    List<StudentClass> sc = new List<StudentClass>(); 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!IsPostBack) 
     { 
      ReportViewer1.ProcessingMode = ProcessingMode.Local; 
      ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report/Student.rdlc"); 
      sc = sr.GetStudents(); 
      IEnumerable<StudentClass> ie; 
      ie = sc.AsQueryable(); 
      ReportDataSource datasource = new ReportDataSource("DataSet1", ie); 
      ReportViewer1.LocalReport.DataSources.Clear(); 
      ReportViewer1.LocalReport.DataSources.Add(datasource); 
     } 

    } 
} 

6.Build E Esegui